-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(tracing): Sync baggage data in Http and envelope headers #5218
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
size-limit report 📦
|
c680f33
to
e04d1b1
Compare
e04d1b1
to
16877b9
Compare
packages/core/src/baseclient.ts
Outdated
normalized.contexts = {}; | ||
normalized.contexts.trace = event.contexts.trace; | ||
normalized.contexts.baggage = event.contexts.baggage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if line 508 is a problem. I thought that contexts could hold arbitrary data 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup contexts can hold arbitrary data!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this line shouldn't exist, right? I checked and it was added in #5171 to normalize trace context data but IIUC what's going on here, we're accidentally erasing all other contexts except the ones we're adding back (which is why I added line 510).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the line for the time being in eebeb6b (happy to revisit this if it's a problem). I checked, the other elements in normalized.contexts are normalized a few lines above:
sentry-javascript/packages/core/src/baseclient.ts
Lines 492 to 494 in eebeb6b
...(event.contexts && { | |
contexts: normalize(event.contexts, depth, maxBreadth), | |
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have that one for trace because of
sentry-javascript/packages/core/src/baseclient.ts
Lines 500 to 506 in 3a938aa
// event.contexts.trace stores information about a Transaction. Similarly, | |
// event.spans[] stores information about child Spans. Given that a | |
// Transaction is conceptually a Span, normalization should apply to both | |
// Transactions and Spans consistently. | |
// For now the decision is to skip normalization of Transactions and Spans, | |
// so this block overwrites the normalized event to add back the original | |
// Transaction information prior to normalization. |
That said, perhaps it's time to rethink that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small questions/suggestions, but otherwise looks good!
packages/integration-tests/suites/tracing/browsertracing/meta/test.ts
Outdated
Show resolved
Hide resolved
As was indicated in #5171 (comment), this will fix #5261 as per the comment here: #5261 (comment) |
Co-authored-by: Katie Byers <[email protected]>
This PR is the continuation of our efforts of propagating baggage data along outgoing Http Requests and to Relay in envelope headers. It syncs the content of the
trace
envelope header with thebaggage
Http header we propagate with outgoing requests. This means that both headers will from now on have the same baggage contents (the envelope header has additional fields that are not part ofBaggage
).This also means that from now on, the
trace
envelope header conforms with the immutability requirements set on baggage. Both headers will callSpan.getBaggage()
to get the baggage data. This method in turn checks if it is allowed to add values to the baggage (see #5205 for more details`). If it is, it will gather all values that are available at that time and mark baggage immutable for potential future calls. This ensures that both headers will get the same data and send consistent data to the next SDK (via outgoing requests) and Relay.ref: https://getsentry.atlassian.net/browse/WEB-937