-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missing an event that contains the current request #111
Comments
Hello! Symfony already has an event for that If you need to do something before Symfony start handling the request I recommend you to create a middleware. |
Hi @Baldinof thanks for your response. Sorry for not being clear enough on my first post. I am using go (roadrunner) middleware for OpenTelemetry described here (https://roadrunner.dev/docs/middleware-otel/2.x/en) and it is executed outside and before the symfony kernel, so I cannot take advantage of your suggestion. For the telemetry itself I and not only me need a way to get the request received by the worker in order to get/calculate the trace id. That is why I am suggesting once the worker receives the request to throw an event which is populated with the request itself. Thanks. |
I'm not sure to understand, here how you can use otel with a middleware. Based on the example here, something like this should work: final class TelemetryMiddleware implements MiddlewareInterface
{
private TracerInterface $tracer;
public function __construct(private LoggerInterface $logger)
{
$this->tracer = (new TracerProviderFactory)->create()->getTracer('example');
}
public function process(Request $request, HttpKernelInterface $next): \Generator
{
$context = TraceContextPropagator::getInstance()->extract($request->headers->all());
$rootSpan = $this->tracer->spanBuilder('root')->setParent($context)->startSpan();
$scope = $rootSpan->activate();
try {
$childSpan = $this->tracer->spanBuilder('child')->startSpan();
yield $next->handle($request);
} finally {
$childSpan->end();
$rootSpan->end();
if ($error = $scope->detach()) {
$this->logger->error('Error detaching scope', ['error' => $error]);
}
}
}
} |
It would be helpful if you provide an event that contains the current request. It can be used for a telemetry, tracing and so on. It could be named WorkerReceivedRequestEvent or you can find better naming.
Thanks in advance!
The text was updated successfully, but these errors were encountered: