-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ref(node): Extract propagation context in tracingHandler
#8425
Conversation
6246e3a
to
0f64764
Compare
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; |
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.
l: could be slightly simplified to:
const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined; | |
const sentryTrace = req.headers?.['sentry-trace'] || undefined; |
?
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 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.
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.
ah, I see, makes sense. 👍
// @ts-expect-error accesing private property for test | ||
return hub.getScope()._propagationContext; |
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.
// @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 :)
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.
Oh TIL! good call.
ref #8352
Introduce the
tracingContextFromHeaders
(first used in #8422) to simplify how trace context is generated in nodetracingHandler
. Then set the propagation context accordingly.