Skip to content

Conversation

@brettmc
Copy link
Contributor

@brettmc brettmc commented Jun 26, 2025

I've just implemented the one stable metric along with recommended attributes here. The metrics generation uses PSR interfaces, so I think we can eventually split it out into its own package and it should work with other frameworks.

Reference: https://opentelemetry.io/docs/specs/semconv/http/http-metrics/

edit: I've been thinking over how to add http.route using this mechanism, and it's really not possible without dodgy and/or ugly hacks. That's got me thinking, what if this was instead implemented as a Span Processor or class similar to this one that's called from our existing SpanProcessorInterface::onEnd(ReadableSpanInterface $span) - at this point we would have access to all the attributes we want, plus request time. It would also have the bonus of working for all http server spans, they just need to be using SemConv correctly to identify themselves (which they should be) - eg kind=server && http.request.method is set

Alternative implementation: open-telemetry/opentelemetry-php#1651

@brettmc brettmc requested a review from a team as a code owner June 26, 2025 01:18
@codecov
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.48%. Comparing base (1d5099d) to head (292d756).
⚠️ Report is 43 commits behind head on main.

Files with missing lines Patch % Lines
...strumentation/Slim/src/PsrServerRequestMetrics.php 90.90% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #396      +/-   ##
============================================
+ Coverage     82.82%   83.48%   +0.65%     
- Complexity     1948     1967      +19     
============================================
  Files           142      144       +2     
  Lines          8142     8215      +73     
============================================
+ Hits           6744     6858     +114     
+ Misses         1398     1357      -41     
Flag Coverage Δ
Aws 92.59% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Instrumentation/AwsSdk 81.13% <ø> (ø)
Instrumentation/CakePHP 20.40% <ø> (ø)
Instrumentation/CodeIgniter 73.55% <ø> (ø)
Instrumentation/Curl 90.42% <ø> (ø)
Instrumentation/Doctrine 91.98% <ø> (-0.75%) ⬇️
Instrumentation/ExtAmqp 88.48% <ø> (ø)
Instrumentation/ExtRdKafka 86.11% <ø> (ø)
Instrumentation/Guzzle 75.58% <ø> (ø)
Instrumentation/HttpAsyncClient 78.04% <ø> (ø)
Instrumentation/IO 70.68% <ø> (ø)
Instrumentation/Laravel 69.68% <ø> (+5.77%) ⬆️
Instrumentation/MongoDB 74.28% <ø> (ø)
Instrumentation/MySqli 95.81% <ø> (ø)
Instrumentation/OpenAIPHP 87.21% <ø> (ø)
Instrumentation/PDO 94.21% <ø> (ø)
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/Slim 86.98% <92.59%> (+0.87%) ⬆️
Instrumentation/Symfony 84.74% <ø> (ø)
Instrumentation/Yii 77.50% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/Instana 98.11% <ø> (ø)
Propagation/ServerTiming 100.00% <ø> (ø)
Propagation/TraceResponse 100.00% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/RuleBased 33.51% <ø> (ø)
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.

Files with missing lines Coverage Δ
...c/Instrumentation/Slim/src/SlimInstrumentation.php 86.23% <100.00%> (+0.38%) ⬆️
...strumentation/Slim/src/PsrServerRequestMetrics.php 90.90% <90.90%> (ø)

... and 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 1d5099d...292d756. Read the comment docs.

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

@brettmc brettmc mentioned this pull request Jun 27, 2025
@brettmc
Copy link
Contributor Author

brettmc commented Jul 22, 2025

Back to draft. Possibly it can be improved in future with the tracking mechanism proposed for PDO metrics...

@brettmc brettmc marked this pull request as draft July 22, 2025 01:13
@brettmc brettmc closed this Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant