Skip to content

ref(serverless): Extract propagation context#8429

Merged
AbhiPrasad merged 2 commits intodevelopfrom
abhi-twp-serverless
Jul 4, 2023
Merged

ref(serverless): Extract propagation context#8429
AbhiPrasad merged 2 commits intodevelopfrom
abhi-twp-serverless

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Contributor

ref #8352

Introduce the tracingContextFromHeaders (first used in #8422) to simplify how trace context is generated by serverless tracing handlers. 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 17:02
@AbhiPrasad AbhiPrasad self-assigned this Jun 29, 2023
Comment on lines +281 to +284
const sentryTrace =
eventWithHeaders.headers && isString(eventWithHeaders.headers['sentry-trace'])
? eventWithHeaders.headers['sentry-trace']
: undefined;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

as we are already using optional chaining, might as well use it here as well ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need the isString check - see #8425 (comment) for more details.

const dynamicSamplingContext = baggageHeaderToDynamicSamplingContext(baggageHeader);

const hub = getCurrentHub();
const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@AbhiPrasad AbhiPrasad merged commit 02e5035 into develop Jul 4, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-twp-serverless 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