opentelemetry-php-contrib icon indicating copy to clipboard operation
opentelemetry-php-contrib copied to clipboard

Fix boundaries for Symfony HttpKernel auto instrumentation

Open dciprian-petrisor opened this issue 1 year ago • 13 comments

Fixes https://github.com/open-telemetry/opentelemetry-php/issues/1443

dciprian-petrisor avatar Nov 28 '24 18:11 dciprian-petrisor

Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one.

welcome[bot] avatar Nov 28 '24 18:11 welcome[bot]

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: dciprian-petrisor / name: Petrisor Ciprian Daniel (24e30e19bc19e8c6393bcc42da2ca7676f463f71)

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 82.81%. Comparing base (3d6f839) to head (24e30e1). :warning: Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #317      +/-   ##
============================================
- Coverage     82.85%   82.81%   -0.04%     
+ Complexity     2353     2309      -44     
============================================
  Files           164      159       -5     
  Lines          9563     9256     -307     
============================================
- Hits           7923     7665     -258     
+ Misses         1640     1591      -49     
Flag Coverage Δ
Aws 93.41% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.42% <ø> (ø)
Instrumentation/AwsSdk 81.13% <ø> (ø)
Instrumentation/CakePHP 20.40% <ø> (ø)
Instrumentation/CodeIgniter 78.99% <ø> (ø)
Instrumentation/Curl 87.66% <ø> (ø)
Instrumentation/Doctrine 92.92% <ø> (ø)
Instrumentation/ExtAmqp 88.48% <ø> (ø)
Instrumentation/ExtRdKafka 86.11% <ø> (ø)
Instrumentation/Guzzle 75.58% <ø> (ø)
Instrumentation/HttpAsyncClient 78.04% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 71.66% <ø> (ø)
Instrumentation/MongoDB 74.28% <ø> (ø)
Instrumentation/MySqli 95.81% <ø> (ø)
Instrumentation/OpenAIPHP 87.21% <ø> (ø)
Instrumentation/PDO 94.21% <ø> (ø)
Instrumentation/PostgreSql 93.54% <ø> (ø)
Instrumentation/Psr14 76.47% <ø> (ø)
Instrumentation/Psr15 89.15% <ø> (ø)
Instrumentation/Psr16 97.50% <ø> (ø)
Instrumentation/Psr18 77.46% <ø> (ø)
Instrumentation/Psr3 67.01% <ø> (ø)
Instrumentation/Psr6 97.61% <ø> (ø)
Instrumentation/ReactPHP 99.45% <ø> (ø)
Instrumentation/Session 94.52% <ø> (ø)
Instrumentation/Slim 84.28% <ø> (ø)
Instrumentation/Symfony ?
Instrumentation/Yii 83.05% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace 89.77% <ø> (ø)
Propagation/Instana 98.11% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/RuleBased 33.51% <ø> (ø)
Sampler/Xray 78.23% <ø> (ø)
Shims/OpenTracing 92.45% <ø> (ø)
Symfony 87.81% <ø> (ø)
Utils/Test 87.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more. see 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3d6f839...24e30e1. Read the comment docs.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 03 '24 04:12 codecov[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 05:04 stale[bot]

Just running into the exact same issue in a project I am working on. Is this on the horizon to be merged any time soon?

jamespavett avatar Jun 09 '25 20:06 jamespavett

Just running into the exact same issue in a project I am working on. Is this on the horizon to be merged any time soon?

No. I'm not sure of the current state. It at least needs to be rebased given its age, and there's some discussion that didn't conclude (and I don't know enough Symfony to make a call myself) @dciprian-petrisor ?

brettmc avatar Jun 11 '25 04:06 brettmc

Just running into the exact same issue in a project I am working on. Is this on the horizon to be merged any time soon?

No. I'm not sure of the current state. It at least needs to be rebased given its age, and there's some discussion that didn't conclude (and I don't know enough Symfony to make a call myself) @dciprian-petrisor ?

Hi, I'll look into this over the weekend and if you all agree we could merge it.

dciprian-petrisor avatar Jun 13 '25 05:06 dciprian-petrisor

I've rebased this PR.

After a brief look with fresh eyes, given it's been some time since this PR had activity, here are my conclusions:

  1. The implementation in this PR covers the 'normal' execution of any Symfony HTTP Request, minus the situation where any of the following calls in HttpKernelRunner would fail miserably:
fastcgi_finish_request();

or

litespeed_finish_request();

or

Response::closeOutputBuffers(0, true);
flush();

All three of these failing indicate a severe problem and I have personally never encountered failures of them. These calls failing would indicate issues with FASTCGI/PHP internals or the SAPI.

  1. In any other situation, one of the following two outcomes can happen:
  • the post hook of handle runs whenever an exception occurs/is thrown while processing the Symfony request. otherwise, a Response object is returned from handle.
  • the terminate call is always made when handle does not throw.

Both of these will finalize the trace.

In summary, I believe this implementation is good as-is. Regarding the documentation, if you can give me a few hints as to where to document it, I would gladly do it.

dciprian-petrisor avatar Jun 16 '25 16:06 dciprian-petrisor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 19 '25 03:07 stale[bot]

In there any chance of getting some progress on this? Realise @dciprian-petrisor rebased this a couple of months back.

This issue currently causes quite a bit of pain when using the Symfony autoinstrumentation libaries.

jamespavett avatar Sep 29 '25 09:09 jamespavett

Very sorry, I didn't see the update. @dciprian-petrisor are you able to (again) resolve conflicts?

brettmc avatar Sep 29 '25 10:09 brettmc

@brettmc just did

dciprian-petrisor avatar Sep 29 '25 16:09 dciprian-petrisor

Sorry to chase again, any idea when we might see this merged / released @brettmc?

jamespavett avatar Nov 24 '25 15:11 jamespavett