Skip to content
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

Add ServerTiming response propagator #213

Merged
merged 7 commits into from
Nov 26, 2023

Conversation

cedricziel
Copy link
Contributor

@cedricziel cedricziel commented Nov 23, 2023

This adds a response propagator for server-timings headers.

Server-Timing headers are especially useful as they are accessible for client side technology like RUM libraries. This is true even for the initial page-load. This makes server-timing the perfect vehicle to send the trace-id to the client for context-assumption, even without nasty hacks like meta html elements.

This approach has been demonstrated by vendors like Splunk and Instana. As there is currently no response propagation format agreed on in OpenTelemetry, the new package adds one as well. In a later iteration, these should optimally be backed by spec and then unified. For now, the interface is duplicated to avoid yet another package to be created.

Note to reviewers: The Symfony tests are failing, because the package referenced doesn't exist yet.

Copy link

codecov bot commented Nov 23, 2023

Codecov Report

Merging #213 (5b3801c) into main (f3e21f4) will increase coverage by 1.80%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #213      +/-   ##
============================================
+ Coverage     32.02%   33.82%   +1.80%     
+ Complexity      878      853      -25     
============================================
  Files            79       76       -3     
  Lines          3360     3225     -135     
============================================
+ Hits           1076     1091      +15     
+ Misses         2284     2134     -150     
Flag Coverage Δ
7.4 46.73% <100.00%> (+0.38%) ⬆️
8.0 33.81% <100.00%> (+1.94%) ⬆️
8.1 33.84% <100.00%> (+1.94%) ⬆️
8.2 33.77% <100.00%> (+1.80%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...gation/ServerTiming/src/ServerTimingPropagator.php 100.00% <100.00%> (ø)

... and 7 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 f3e21f4...5b3801c. Read the comment docs.

@cedricziel cedricziel marked this pull request as ready for review November 23, 2023 19:45
@cedricziel cedricziel requested a review from a team November 23, 2023 19:45
@cedricziel
Copy link
Contributor Author

@brettmc the TextMapPropagator and the way it is used currently for requests is not suited for ServerTiming propagation.

If we registered ServerTimingPropagator there and used Globals::propagator()->inject(), not just server-timings would be propagated into the response, but also the other configured propagation formats, which is not the desired behavior. Same way, if server-timings was a regularly activated propagator, it would be propagated forward, which is also not the desired behavior.

What I thought about, is to amend the core to offer a dedicated method for response propagators:

// register response propagator in _register.php
\OpenTelemetry\SDK\Registry::registerTextMapResponsePropagator(
   'server-timing',
    ServerTimingPropagator::getInstance()
);

// get a composite propagator with _just_ response propagators
Globals::responsePropagator()->inject($carrier);

@brettmc
Copy link
Collaborator

brettmc commented Nov 24, 2023

What I thought about, is to amend the core to offer a dedicated method for response propagators

Yes, you're absolutely right. Are we confident enough in the idea of a response propagator to attempt that in core? I feel like it's something that should be spec-driven.

Copy link
Collaborator

@brettmc brettmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - I think a future TODO to formalize in core the idea of a response propagator, possibly based on a spec enhancement.

@cedricziel
Copy link
Contributor Author

I feel like it's something that should be spec-driven.

💯

@jpkrohling and I want to propose a spec amendment somewhere in the next 3 months

@brettmc
Copy link
Collaborator

brettmc commented Nov 26, 2023

@cedricziel one thing missing is an entry in .gitsplit.yaml for the new package.
I've created https://github.com/opentelemetry-php/contrib-propagator-server-timing as the target repo

@cedricziel
Copy link
Contributor Author

@brettmc pushed!

@brettmc brettmc merged commit 0dda869 into open-telemetry:main Nov 26, 2023
63 of 66 checks passed
@cedricziel cedricziel deleted the server-timing branch November 26, 2023 22:46
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.

2 participants