Skip to content
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

Merged
merged 8 commits into from
Jul 4, 2023

Conversation

AbhiPrasad
Copy link
Member

ref #8352

Introduce the tracingContextFromHeaders (first used in #8422) to simplify how trace context is generated in node tracingHandler . Then set the propagation context accordingly.

@AbhiPrasad AbhiPrasad requested review from a team, mydea and ale-cota and removed request for a team June 29, 2023 16:13
@AbhiPrasad AbhiPrasad self-assigned this Jun 29, 2023
Base automatically changed from abhi-twp-node-env to develop June 29, 2023 16:37
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;
Copy link
Member

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:

Suggested change
const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;
const sentryTrace = req.headers?.['sentry-trace'] || undefined;

?

Copy link
Member Author

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.

Copy link
Member

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. 👍

Comment on lines +213 to +214
// @ts-expect-error accesing private property for test
return hub.getScope()._propagationContext;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh TIL! good call.

@AbhiPrasad AbhiPrasad merged commit a3178f7 into develop Jul 4, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-twp-node-req branch July 4, 2023 13:43
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.

2 participants