Skip to content

Commit

Permalink
FRW-9126 As a Project Engineer I want to be able to send custom event…
Browse files Browse the repository at this point in the history
…s (span events) via spryker/monitoring module (#11277)

FRW-9126 As a Project Engineer I want to be able to send custom events (span events) via spryker/monitoring module
  • Loading branch information
gechetspr authored Jan 13, 2025
1 parent fcfb7a4 commit 74ed644
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"spryker/event-dispatcher-extension": "^1.0.0",
"spryker/kernel": "^3.30.0",
"spryker/locale": "^3.0.0 || ^4.0.0",
"spryker/monitoring-extension": "^1.0.0",
"spryker/monitoring-extension": "^1.1.0",
"spryker/store": "^1.0.0",
"spryker/symfony": "^3.5.0",
"spryker/util-network": "^1.0.0"
Expand Down
18 changes: 18 additions & 0 deletions src/Spryker/Service/Monitoring/Model/Monitoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Spryker\Service\Monitoring\Model;

use Spryker\Service\MonitoringExtension\Dependency\Plugin\CustomEventsMonitoringExtensionPluginInterface;

class Monitoring implements MonitoringInterface
{
/**
Expand Down Expand Up @@ -154,4 +156,20 @@ public function addCustomTracer(string $tracer): void
$monitoringExtensionPlugin->addCustomTracer($tracer);
}
}

/**
* @param string $name
* @param array $attributes
*
* @return void
*/
public function addCustomEvent(string $name, array $attributes = []): void
{
$this->setApplicationName();
foreach ($this->monitoringExtensionPlugins as $monitoringExtensionPlugin) {
if ($monitoringExtensionPlugin instanceof CustomEventsMonitoringExtensionPluginInterface) {
$monitoringExtensionPlugin->addEvent($name, $attributes);
}
}
}
}
15 changes: 15 additions & 0 deletions src/Spryker/Service/Monitoring/MonitoringService.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,19 @@ public function addCustomTracer(string $tracer): void
{
$this->getFactory()->createMonitoring()->addCustomTracer($tracer);
}

/**
* {@inheritDoc}
*
* @api
*
* @param string $name
* @param array $attributes
*
* @return void
*/
public function addCustomEvent(string $name, array $attributes = []): void
{
$this->getFactory()->createMonitoring()->addCustomEvent($name, $attributes);
}
}
13 changes: 13 additions & 0 deletions src/Spryker/Service/Monitoring/MonitoringServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,17 @@ public function addCustomParameter(string $key, $value): void;
* @return void
*/
public function addCustomTracer(string $tracer): void;

/**
* Specification:
* - Adds custom event.
*
* @api
*
* @param string $name
* @param array $attributes
*
* @return void
*/
public function addCustomEvent(string $name, array $attributes = []): void;
}

0 comments on commit 74ed644

Please sign in to comment.