{{ message }}
feat(tracing): Handle tracestate HTTP headers/correlation context envelope headers - #971
Merged
lobsterkatie merged 24 commits intoFeb 26, 2021
Conversation
lobsterkatie
force-pushed
the
kmclb-trace-context-in-envelope-header
branch
3 times, most recently
from
January 15, 2021 02:33
a352af7 to
4f188d3
Compare
RaduW
suggested changes
Jan 15, 2021
RaduW
left a comment
Contributor
There was a problem hiding this comment.
Nice implementation.
I'm not really familiar with the SDK so I might miss more subtle points.
I think you have a small bug on extracting the elements from the tracestate header.
Since it is a bit tricky I would add a parameterized test for extract_tracestate_data in which I would pass a few plausible headers to make sure it does what we need.
I would also do a separate test for extract_sentrytrace_data to make sure I'm not missing anything
rhcarvalho
reviewed
Jan 18, 2021
RaduW
approved these changes
Jan 20, 2021
RaduW
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me.
I would move the massaging of '=' out of capture_event and into from_base64 but it's you call.
lobsterkatie
force-pushed
the
kmclb-trace-context-poc
branch
from
January 25, 2021 16:45
3389284 to
2377371
Compare
lobsterkatie
force-pushed
the
kmclb-trace-context-in-envelope-header
branch
2 times, most recently
from
January 25, 2021 16:49
9a878fc to
41dc24a
Compare
lobsterkatie
force-pushed
the
kmclb-trace-context-poc
branch
from
January 25, 2021 22:02
2377371 to
eed2ca1
Compare
lobsterkatie
force-pushed
the
kmclb-trace-context-in-envelope-header
branch
from
January 25, 2021 22:08
41dc24a to
91cfd62
Compare
lobsterkatie
marked this pull request as ready for review
January 26, 2021 02:48
tracestate correlation context to envelope headerstracestate HTTP headers/correlation context envelope headers
lobsterkatie
force-pushed
the
kmclb-trace-context-in-envelope-header
branch
from
January 26, 2021 03:08
91cfd62 to
464886e
Compare
Member
Member
…velope is created
lobsterkatie
force-pushed
the
kmclb-trace-context-poc
branch
from
February 26, 2021 01:45
eed2ca1 to
84b225d
Compare
lobsterkatie
force-pushed
the
kmclb-trace-context-in-envelope-header
branch
from
February 26, 2021 01:46
464886e to
97a4aaf
Compare
lobsterkatie
added a commit
that referenced
this pull request
Sep 16, 2021
This introduces handling of the `tracestate` header, as described in the W3C Trace Context spec[1] and our own corresponding spec[2]. Key features: - Deprecation of `from_traceparent` in favor of `continue_from_headers`, which now propagates both incoming `sentry-trace` and incoming `tracestate` headers. - Propagation of `tracestate` value as a header on outgoing HTTP requests when they're made during a transaction. - Addition of `tracestate` data to transaction envelope headers. Supporting changes: - New utility methods for converting strings to and from base64. - Some refactoring vis-à-vis the links between transactions, span recorders, and spans. See #1173 and #1184. - Moving of some tracing code to a separate `tracing_utils` file. Note: `tracestate` handling is currently feature-gated by the flag `propagate_tracestate` in the `_experiments` SDK option. More details can be found in the main PR on this branch, #971. [1] https://www.w3.org/TR/trace-context/#tracestate-header [2] https://develop.sentry.dev/sdk/performance/trace-context/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This PR is an initial implementation of the official
tracestatespec (detailed here), which specifies a multi-vendor, vendor-neutral method of propagating trace data between services. The basic format of atracestateheader isvendor1=value1,vendor2=value2,vendor3=value3,....Key Behaviors:
tracestateheader is parsed, and Sentry and third-party portions are stored separately on the transactiontracestatevalue is calculated and stored on the transactiontracestateheader of the formsentry=sentry_value,vendor1=value1,vendor2=value2(in other words, wherever the Sentry data was in the incoming list, it's moved to be the first entry)tracestatevalue in their envelope headers* Now that there's more than one header, the
from_traceparentmethod mentioned in an older version of our tracing spec (since replaced byfrom_sentrytracein the spec, but not the SDK) is deprecated in favor of two new helper functions called fromcontinue_from_headers.** Error events with attachments just because those are the only ones currently sent in envelopes.
Sentry's
tracestateValue:{ "trace_id": ... , "release": ... , "environment": ... , "public_key": ... }, base64-encoding it, and stripping off any trailing=. (releaseandenvironmentreflect the values set insentry_sdk.init(), andpublic_keycomes from the part of the DSN between thehttps://and the@xxx.ingest.sentry.io.)Known Limitations:
Compared to the spec, this does not handle:
tracestateheadersx=y,,z=w)tracestateheader valuetracestatevalue or the overalltracestateheaderIt also does not consume, create, or propagate
traceparentheaders. (We continue to use our own similarsentry-traceheader.)Follow-up Tasks
continue_from_headers/helper function model, and update dev docstracestateheaders and handle third-partytracestatevalues