MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / suppressTracing

Function suppressTracing

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

Source from the content-addressed store, hash-verified

272
273/** Suppress tracing in the given callback, ensuring no spans are generated inside of it. */
274export function suppressTracing<T>(callback: () => T): T {
275 const acs = getAcs();
276
277 if (acs.suppressTracing) {
278 return acs.suppressTracing(callback);
279 }
280
281 return withScope(scope => {
282 // Note: We do not wait for the callback to finish before we reset the metadata
283 // the reason for this is that otherwise, in the browser this can lead to very weird behavior
284 // as there is only a single top scope, if the callback takes longer to finish,
285 // other, unrelated spans may also be suppressed, which we do not want
286 // so instead, we only suppress tracing synchronoysly in the browser
287 scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: true });
288 const res = callback();
289 scope.setSDKProcessingMetadata({ [SUPPRESS_TRACING_KEY]: undefined });
290 return res;
291 });
292}
293
294/** Check if tracing is suppressed. */
295export function isTracingSuppressed(scope = getCurrentScope()): boolean {

Callers 10

trace.test.tsFile · 0.90
makeRequestFunction · 0.90
createRequestExecutorFunction · 0.90
makeRequestFunction · 0.90
makeRequestFunction · 0.90
propagator.test.tsFile · 0.90
trace.test.tsFile · 0.90
_startSpanFunction · 0.90
startInactiveSpanFunction · 0.90
makeRequestFunction · 0.90

Calls 4

withScopeFunction · 0.90
getAcsFunction · 0.85
callbackFunction · 0.50

Tested by

no test coverage detected