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

Function startInactiveSpan

packages/opentelemetry/src/trace.ts:148–175  ·  view source on GitHub ↗
(options: OpenTelemetrySpanContext)

Source from the content-addressed store, hash-verified

146 * it may just be a non-recording span if the span is not sampled or if tracing is disabled.
147 */
148export function startInactiveSpan(options: OpenTelemetrySpanContext): Span {
149 const tracer = getTracer();
150
151 const { name, parentSpan: customParentSpan } = options;
152
153 // If `options.parentSpan` is defined, we want to wrap the callback in `withActiveSpan`
154 const wrapper = getActiveSpanWrapper<Span>(customParentSpan);
155
156 return wrapper(() => {
157 const activeCtx = getContext(options.scope, options.forceTransaction);
158 const missingRequiredParent = options.onlyIfParent && !trace.getSpan(activeCtx);
159 let ctx = missingRequiredParent ? suppressTracing(activeCtx) : activeCtx;
160
161 if (missingRequiredParent) {
162 getClient()?.recordDroppedEvent('no_parent_span', 'span');
163 }
164
165 const spanOptions = getSpanOptions(options);
166
167 if (!hasSpansEnabled()) {
168 ctx = isTracingSuppressed(ctx) ? ctx : suppressTracing(ctx);
169 }
170
171 const span = tracer.startSpan(name, spanOptions, ctx);
172 patchSpanEnd(span);
173 return span;
174 });
175}
176
177/**
178 * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be

Callers 2

trace.test.tsFile · 0.90

Calls 11

suppressTracingFunction · 0.90
getClientFunction · 0.90
hasSpansEnabledFunction · 0.90
isTracingSuppressedFunction · 0.90
getTracerFunction · 0.85
wrapperFunction · 0.85
getContextFunction · 0.85
getSpanOptionsFunction · 0.85
getActiveSpanWrapperFunction · 0.70
patchSpanEndFunction · 0.70
startSpanMethod · 0.45

Tested by

no test coverage detected