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

Function getParentSpan

packages/core/src/tracing/trace.ts:602–626  ·  view source on GitHub ↗
(scope: Scope, customParentSpan: Span | null | undefined)

Source from the content-addressed store, hash-verified

600}
601
602function getParentSpan(scope: Scope, customParentSpan: Span | null | undefined): SentrySpan | undefined {
603 // always use the passed in span directly
604 if (customParentSpan) {
605 return customParentSpan as SentrySpan;
606 }
607
608 // This is different from `undefined` as it means the user explicitly wants no parent span
609 if (customParentSpan === null) {
610 return undefined;
611 }
612
613 const span = _getSpanForScope(scope) as SentrySpan | undefined;
614
615 if (!span) {
616 return undefined;
617 }
618
619 const client = getClient();
620 const options: Partial<ClientOptions> = client ? client.getOptions() : {};
621 if (options.parentSpanIsAlwaysRootSpan) {
622 return getRootSpan(span) as SentrySpan;
623 }
624
625 return span;
626}
627
628function getActiveSpanWrapper<T>(parentSpan: Span | undefined | null): (callback: () => T) => T {
629 return parentSpan !== undefined

Callers 3

startSpanFunction · 0.85
startSpanManualFunction · 0.85
startInactiveSpanFunction · 0.85

Calls 4

_getSpanForScopeFunction · 0.90
getClientFunction · 0.90
getRootSpanFunction · 0.85
getOptionsMethod · 0.65

Tested by

no test coverage detected