ref(node): Extract propagation context in tracingHandler#8425
Merged
AbhiPrasad merged 8 commits intodevelopfrom Jul 4, 2023
Merged
ref(node): Extract propagation context in tracingHandler#8425AbhiPrasad merged 8 commits intodevelopfrom
tracingHandler#8425AbhiPrasad merged 8 commits intodevelopfrom
Conversation
6246e3a to
0f64764
Compare
mydea
reviewed
Jun 30, 2023
| req.headers && isString(req.headers['sentry-trace']) && extractTraceparentData(req.headers['sentry-trace']); | ||
| const incomingBaggageHeaders = req.headers?.baggage; | ||
| const dynamicSamplingContext = baggageHeaderToDynamicSamplingContext(incomingBaggageHeaders); | ||
| const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined; |
Member
There was a problem hiding this comment.
l: could be slightly simplified to:
Suggested change
| const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined; | |
| const sentryTrace = req.headers?.['sentry-trace'] || undefined; |
?
Contributor
Author
There was a problem hiding this comment.
We have the isString check here because req.headers['sentry-trace'] can provide an array, and we currently don't consider that valid.
I'd rather come back and re-evaluate that decision for every header usage, but for now don't want to unblock this change in particular. Adding as a TODO to the GH issue.
mydea
reviewed
Jun 30, 2023
Comment on lines
+213
to
+214
| // @ts-expect-error accesing private property for test | ||
| return hub.getScope()._propagationContext; |
Member
There was a problem hiding this comment.
Suggested change
| // @ts-expect-error accesing private property for test | |
| return hub.getScope()._propagationContext; | |
| return hub.getScope()['_propagationContext']; |
You can access private properties without TS complaining and without @ts- comment this way - we are using this in replay tests quite a lot :)
Contributor
Author
There was a problem hiding this comment.
Oh TIL! good call.
mydea
approved these changes
Jul 3, 2023
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.
ref #8352
Introduce the
tracingContextFromHeaders(first used in #8422) to simplify how trace context is generated in nodetracingHandler. Then set the propagation context accordingly.