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

Function startInactiveSpan

packages/core/src/tracing/trace.ts:178–213  ·  view source on GitHub ↗
(options: StartSpanOptions)

Source from the content-addressed store, hash-verified

176 * it may just be a non-recording span if the span is not sampled or if tracing is disabled.
177 */
178export function startInactiveSpan(options: StartSpanOptions): Span {
179 const acs = getAcs();
180 if (acs.startInactiveSpan) {
181 return acs.startInactiveSpan(options);
182 }
183
184 const spanArguments = parseSentrySpanArguments(options);
185 const { forceTransaction, parentSpan: customParentSpan } = options;
186
187 // If `options.scope` is defined, we use this as as a wrapper,
188 // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`
189 const wrapper = options.scope
190 ? (callback: () => Span) => withScope(options.scope, callback)
191 : customParentSpan !== undefined
192 ? (callback: () => Span) => withActiveSpan(customParentSpan, callback)
193 : (callback: () => Span) => callback();
194
195 return wrapper(() => {
196 const scope = getCurrentScope();
197 const parentSpan = getParentSpan(scope, customParentSpan);
198 const client = getClient();
199
200 const missingRequiredParent = options.onlyIfParent && !parentSpan;
201
202 if (missingRequiredParent) {
203 return startMissingRequiredParentSpan(scope, client);
204 }
205
206 return createChildOrRootSpan({
207 parentSpan,
208 spanArguments,
209 forceTransaction,
210 scope,
211 });
212 });
213}
214
215/**
216 * Continue a trace from `sentry-trace` and `baggage` values.

Callers 15

setupFunction · 0.90
setupH3TracingChannelsFunction · 0.90
setupSrvxTracingChannelsFunction · 0.90
setupFunction · 0.90
setupDeferredFunction · 0.90
setupOnceFunction · 0.90
startRequestSpanHookFunction · 0.90
setupCommandChannelFunction · 0.90
setupBatchChannelFunction · 0.90
setupConnectChannelFunction · 0.90

Calls 11

withScopeFunction · 0.90
getCurrentScopeFunction · 0.90
getClientFunction · 0.90
getAcsFunction · 0.85
parseSentrySpanArgumentsFunction · 0.85
wrapperFunction · 0.85
getParentSpanFunction · 0.85
createChildOrRootSpanFunction · 0.85
withActiveSpanFunction · 0.70
callbackFunction · 0.50

Tested by 2

setupFunction · 0.72
setupDeferredFunction · 0.72