Skip to content

Commit

Permalink
fix(node): Set propagation context even when tracingOptions are not d…
Browse files Browse the repository at this point in the history
…efined (#8517)
  • Loading branch information
AbhiPrasad committed Jul 12, 2023
1 parent 6be123e commit 5f7a0fb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions packages/node/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ export function tracingHandler(): (
return next();
}

if (!hasTracingEnabled(options)) {
__DEBUG_BUILD__ &&
logger.warn(
'Sentry `tracingHandler` is being used, but tracing is disabled. Please enable tracing by setting ' +
'either `tracesSampleRate` or `tracesSampler` in your `Sentry.init()` options.',
);
return next();
}

const sentryTrace = req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined;
const baggage = req.headers?.baggage;
const { traceparentData, dynamicSamplingContext, propagationContext } = tracingContextFromHeaders(
Expand All @@ -70,6 +61,10 @@ export function tracingHandler(): (
);
hub.getScope().setPropagationContext(propagationContext);

if (!hasTracingEnabled(options)) {
return next();
}

const [name, source] = extractPathForTransaction(req, { path: true, method: true });
const transaction = startTransaction(
{
Expand Down

0 comments on commit 5f7a0fb

Please sign in to comment.