This library supports Span traces of Symfony Messenger messages.
-
Install via composer
composer require pccomponentes/apm-symfony-messenger
In all cases, an already created instance of ElasticApmTracer is assumed.
<?php
declare(strict_types=1);
class TextNameExtractor implements PcComponentes\ElasticAPM\Symfony\Component\Messenger\NameExtractor
{
public function execute($message): string
{
if (false === is_string($message)) {
throw new InvalidArgumentException('The parameter must be of type string');
}
return $message;
}
}
$apmMiddleware = new PcComponentes\ElasticAPM\Symfony\Component\Messenger\ApmMiddleware(
$apmTracer, /** \ZoiloMora\ElasticAPM\ElasticApmTracer instance. */
new TextNameExtractor(),
);
$bus = new Symfony\Component\Messenger\MessageBus([
$apmMiddleware
]);
app.bus:
class: Symfony\Component\Messenger\MessageBus
arguments:
$middlewareHandlers:
- '@app.bus.middleware.apm'
app.bus.middleware.apm:
class: PcComponentes\ElasticAPM\Symfony\Component\Messenger\ApmMiddleware
arguments:
$elasticApmTracer: '@apm.tracer' # \ZoiloMora\ElasticAPM\ElasticApmTracer instance.
$nameExtractor: '@app.bus.middleware.apm.name_extractor'
app.bus.middleware.apm.name_extractor:
class: ExampleTextNameExtractor
Licensed under the MIT license
Read LICENSE for more information