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

implement w3c trace context response propagation #998

Merged
merged 5 commits into from
Mar 24, 2023

Conversation

wperron
Copy link
Contributor

@wperron wperron commented Mar 16, 2023

Adds a TraceContextResponsePropagator to the contrib crate implementing the W3C Trace Context Response Header.

Fixes #523

@wperron wperron requested a review from a team March 16, 2023 13:53
global::set_text_map_propagator(TraceContextPropagator::new());

// Install stdout exporter pipeline to be able to retrieve the collected spans.
// For the demonstration, use `Sampler::AlwaysOn` sampler to sample all traces. In a production
Copy link
Member

Choose a reason for hiding this comment

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

nit: do we need to explicitly set AlwaysOn here? The default would be parent_based(ALwaysOn), which should be good enough for this example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO this is fine, it clearly illustrates that AlwaysOn is being used for demonstration purposes only, it ensures it always gets logged to stdout no matter what happens in the client example, for a demo this makes sense to me.

@wperron
Copy link
Contributor Author

wperron commented Mar 16, 2023

@cijothomas I'll be honest, for the example, I simply copied over what's in examples/http and added bits to inject/extract the traceresponse

@wperron
Copy link
Contributor Author

wperron commented Mar 16, 2023

I'm also not sure what's up with the CI/coverage job, it works fine locally 🤔

@cijothomas
Copy link
Member

@cijothomas I'll be honest, for the example, I simply copied over what's in examples/http and added bits to inject/extract the traceresponse

np! I will take a look at the existing examples and propose some improvements. (I am totally new to Rust and this Repo :))

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (480dfce) 69.9% compared to head (cb0f4f3) 69.9%.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #998   +/-   ##
=====================================
  Coverage   69.9%   69.9%           
=====================================
  Files        116     116           
  Lines       9027    9027           
=====================================
  Hits        6316    6316           
  Misses      2711    2711           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wperron wperron force-pushed the response-text-map-propagator branch from 9122b53 to aeaca27 Compare March 23, 2023 13:57

let cx = Context::current_with_span(span);

cx.span().add_event("handling this...", Vec::new());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cx.span().add_event("handling this...", Vec::new());
span.add_event("handling this...", Vec::new());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change would also require importing opentelemetry::trace::Span which would make span a BoxedSpan as opposed to a SpanRef, which also means making span mutable because BoxedSpan::add_event takes a mutable reference, and moving the definition of cx further down because Context::current_with_span moves the span, and BoxedSpan doesn't implement Clone.

I don't mind doing this change, but is it really necessary, when the purpose here is to illustrate how traceresponse works?

Copy link
Member

Choose a reason for hiding this comment

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

No need of changing. (I am Rust newbie, so my comments could be wrong!)

@jtescher jtescher merged commit 01dade6 into open-telemetry:main Mar 24, 2023
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.

Support injecting a context in to a response
3 participants