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

Function startNewTrace

packages/core/src/tracing/trace.ts:321–335  ·  view source on GitHub ↗
(callback: () => T)

Source from the content-addressed store, hash-verified

319 * or page will automatically create a new trace.
320 */
321export function startNewTrace<T>(callback: () => T): T {
322 const acs = getAcs();
323 if (acs.startNewTrace) {
324 return acs.startNewTrace(callback);
325 }
326
327 return withScope(scope => {
328 scope.setPropagationContext({
329 traceId: generateTraceId(),
330 sampleRand: safeMathRandom(),
331 });
332 DEBUG_BUILD && debug.log(`Starting a new trace with id ${scope.getPropagationContext().traceId}`);
333 return withActiveSpan(null, callback);
334 });
335}
336
337/**
338 * The placeholder returned from `startSpan*` when `onlyIfParent` is set but there is no parent span.

Callers 5

trace.test.tsFile · 0.90
withMonitorFunction · 0.90
escapeNextjsTracingFunction · 0.90
continueTraceFunction · 0.70

Calls 8

withScopeFunction · 0.90
generateTraceIdFunction · 0.90
safeMathRandomFunction · 0.90
getAcsFunction · 0.85
setPropagationContextMethod · 0.80
getPropagationContextMethod · 0.80
withActiveSpanFunction · 0.70
logMethod · 0.65

Tested by

no test coverage detected