Skip to content

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, ale-cota and mydea 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.

3 participants