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

Function withIsolationScope

packages/core/src/currentScopes.ts:120–140  ·  view source on GitHub ↗
(
  ...rest:
    | [callback: (isolationScope: Scope) => T]
    | [isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T]
)

Source from the content-addressed store, hash-verified

118 * Either creates a new active isolation scope, or sets the given isolation scope as active scope in the given callback.
119 */
120export function withIsolationScope<T>(
121 ...rest:
122 | [callback: (isolationScope: Scope) => T]
123 | [isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T]
124): T {
125 const carrier = getMainCarrier();
126 const acs = getAsyncContextStrategy(carrier);
127
128 // If a scope is defined, we want to make this the active scope instead of the default one
129 if (rest.length === 2) {
130 const [isolationScope, callback] = rest;
131
132 if (!isolationScope) {
133 return acs.withIsolationScope(callback);
134 }
135
136 return acs.withSetIsolationScope(isolationScope, callback);
137 }
138
139 return acs.withIsolationScope(rest[0]);
140}
141
142/**
143 * Get the currently active client.

Callers 15

wrapRequestHandlerFunction · 0.90
domainifyFunction · 0.90
withElysiaFunction · 0.90
scope.test.tsFile · 0.90
feedback.test.tsFile · 0.90
trpcMiddlewareFunction · 0.90
withMonitorFunction · 0.90
applyFunction · 0.90
wrapTransportOnMessageFunction · 0.90
async.test.tsFile · 0.90
sentryRequestHandlerFunction · 0.90

Calls 2

getMainCarrierFunction · 0.90
getAsyncContextStrategyFunction · 0.90

Tested by

no test coverage detected