You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP 8.2.24 (cli) (built: Sep 27 2024 04:16:10) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.24, Copyright (c) Zend Technologies
with Zend OPcache v8.2.24, Copyright (c), by Zend Technologies
with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
Relevant packages:
open-telemetry/opentelemetry-auto-symfony
open-telemetry/opentelemetry-auto-psr14
Steps to reproduce
Install both packages in a Symfony project, enable otel SDK autoloader and fire a request to the application.
What is the expected behavior?
A single trace for the request.
What is the actual behavior?
Two traces, one for the request itself, and one for the Symfony\Component\HttpKernel\Event\TerminateEvent emitted by Symfony at the end of Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner.
Additional context
The problem seems to be the hooks set up in open-telemetry/opentelemetry-auto-symfony:
It hooks into the HttpKernel::handle method. The post hook detaches the scope via scope->detach().
The TerminateEvent is emitted by Symfony however after the post hook runs for HttpKernel::handle, at which point it no longer has a context with a traceId available, so a new one seems to be generated.
Potential solution
Since the HttpKernel extends TerminableInterface which exposes a terminate function, I propose removing the post hook from HttpKernel::handle and registering it on HttpKernel::terminate instead, so that this event is captured properly by opentelemetry-auto-psr14 and part of the same request trace instead of an individual one.
The text was updated successfully, but these errors were encountered:
petrisorciprian-vitals
changed the title
[opentelemetry-php-contrib]
[opentelemetry-php-contrib] Incorrect trace boundaries for Symfony HttpKernel auto instrumentation
Nov 28, 2024
Describe your environment
Relevant packages:
Steps to reproduce
Install both packages in a Symfony project, enable otel SDK autoloader and fire a request to the application.
What is the expected behavior?
A single trace for the request.
What is the actual behavior?
Two traces, one for the request itself, and one for the
Symfony\Component\HttpKernel\Event\TerminateEvent
emitted by Symfony at the end ofSymfony\Component\Runtime\Runner\Symfony\HttpKernelRunner
.Additional context
The problem seems to be the hooks set up in
open-telemetry/opentelemetry-auto-symfony
:It hooks into the
HttpKernel::handle
method. Thepost
hook detaches the scope viascope->detach()
.The
TerminateEvent
is emitted by Symfony however after thepost
hook runs forHttpKernel::handle
, at which point it no longer has a context with a traceId available, so a new one seems to be generated.Potential solution
Since the
HttpKernel
extendsTerminableInterface
which exposes aterminate
function, I propose removing thepost
hook fromHttpKernel::handle
and registering it onHttpKernel::terminate
instead, so that this event is captured properly byopentelemetry-auto-psr14
and part of the same request trace instead of an individual one.The text was updated successfully, but these errors were encountered: