8000 ref(tracing): Various tweaks to tracestate header handling by lobsterkatie · Pull Request #1173 · getsentry/sentry-python · GitHub
[go: up one dir, main page]

Skip to content

ref(tracing): Various tweaks to tracestate header handling #1173

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

Conversation

lobsterkatie
Copy link
Member
@lobsterkatie lobsterkatie commented Aug 27, 2021

Three small changes here, mostly unrelated. Probably easiest to look at this commit by commit.

  • Correct return type of compute_tracestate_entry to correctly return None when we're missing a client or DSN.

  • Let transactions (effectively) point to themselves as the "containing transaction." In order to avoid a circular reference, this is handled through a new property on both spans and transactions. As a result of this change, we can eliminate a good deal of type-checking that we've been doing up until now.

  • Switch tracestate creation to be lazy. Rather than always creating a value in the transaction constructor, we now wait until we need it - either for an outgoing HTTP header or for the envelope header when sending the transaction event.

@lobsterkatie lobsterkatie force-pushed the kmclb-tracestate-lazy-tracestate-random-tweaks branch from 9001cd4 to 14bd3d8 Compare August 27, 2021 05:53
@rhcarvalho rhcarvalho dismissed their stale review August 27, 2021 15:48

Resolved

@lobsterkatie lobsterkatie merged commit 8f8c0bd into kmclb-add-tracestate-header-handling Aug 30, 2021
@lobsterkatie lobsterkatie deleted the kmclb-tracestate-lazy-tracestate-random-tweaks branch August 30, 2021 13:12
lobsterkatie added a commit that referenced this pull request Sep 2, 2021
Three small changes here, mostly unrelated. If you're specifically interested in one of them, it's probably easiest to look at them commit by commit in the PR.

- Correct return type of `compute_tracestate_entry` to correctly return `None` when we're missing a client or DSN.

- Let transactions (effectively) point to themselves as the "containing transaction." In order to avoid a circular reference, this is handled through a new property on both spans and transactions. As a result of this change, we can eliminate a good deal of type-checking that we've been doing up until now.

- Switch `tracestate` creation to be lazy. Rather than always creating a value in the transaction constructor, we now wait until we need it - either for an outgoing HTTP header or for the envelope header when sending the transaction event.
lobsterkatie added a commit that referenced this pull request Sep 13, 2021
Three small changes here, mostly unrelated. If you're specifically interested in one of them, it's probably easiest to look at them commit by commit in the PR.

- Correct return type of `compute_tracestate_entry` to correctly return `None` when we're missing a client or DSN.

- Let transactions (effectively) point to themselves as the "containing transaction." In order to avoid a circular reference, this is handled through a new property on both spans and transactions. As a result of this change, we can eliminate a good deal of type-checking that we've been doing up until now.

- Switch `tracestate` creation to be lazy. Rather than always creating a value in the transaction constructor, we now wait until we need it - either for an outgoing HTTP header or for the envelope header when sending the transaction event.
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/
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.

3 participants
0