MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / continueTrace

Function continueTrace

packages/core/src/tracing/trace.ts:223–250  ·  view source on GitHub ↗
(
  options: {
    sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];
    baggage: Parameters<typeof propagationContextFromHeaders>[1];
  },
  callback: () => V,
)

Source from the content-addressed store, hash-verified

221 * be attached to the incoming trace.
222 */
223export const continueTrace = <V>(
224 options: {
225 sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];
226 baggage: Parameters<typeof propagationContextFromHeaders>[1];
227 },
228 callback: () => V,
229): V => {
230 const carrier = getMainCarrier();
231 const acs = getAsyncContextStrategy(carrier);
232 if (acs.continueTrace) {
233 return acs.continueTrace(options, callback);
234 }
235
236 const { sentryTrace, baggage } = options;
237
238 const client = getClient();
239 const incomingDsc = baggageHeaderToDynamicSamplingContext(baggage);
240 if (client && !shouldContinueTrace(client, incomingDsc?.org_id)) {
241 return startNewTrace(callback);
242 }
243
244 return withScope(scope => {
245 const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);
246 scope.setPropagationContext(propagationContext);
247 _setSpanForScope(scope, undefined);
248 return callback();
249 });
250};
251
252/**
253 * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be

Callers 14

wrapRequestHandlerFunction · 0.90
withElysiaFunction · 0.90
trace.test.tsFile · 0.90
applyFunction · 0.90
_getPatchHandlerMethod · 0.90
sentryRequestHandlerFunction · 0.90
wrapDenoRequestHandlerFunction · 0.90
wrapRequestHandlerFunction · 0.90
wrapRequestHandlerFunction · 0.90
wrappedFunctionFunction · 0.90
patchedOnMessageFunction · 0.90

Calls 11

getMainCarrierFunction · 0.90
getAsyncContextStrategyFunction · 0.90
getClientFunction · 0.90
shouldContinueTraceFunction · 0.90
withScopeFunction · 0.90
_setSpanForScopeFunction · 0.90
setPropagationContextMethod · 0.80
startNewTraceFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected