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

Function getTraceContextFromScope

packages/core/src/currentScopes.ts:152–172  ·  view source on GitHub ↗
(scope: Scope)

Source from the content-addressed store, hash-verified

150 * Get a trace context for the given scope.
151 */
152export function getTraceContextFromScope(scope: Scope): TraceContext {
153 const externalContext = getExternalPropagationContext();
154 if (externalContext) {
155 return { trace_id: externalContext.traceId, span_id: externalContext.spanId };
156 }
157
158 const propagationContext = scope.getPropagationContext();
159
160 const { traceId, parentSpanId, propagationSpanId } = propagationContext;
161
162 const traceContext: TraceContext = {
163 trace_id: traceId,
164 span_id: propagationSpanId || generateSpanId(),
165 };
166
167 if (parentSpanId) {
168 traceContext.parent_span_id = parentSpanId;
169 }
170
171 return traceContext;
172}

Callers 4

_prepareEventFunction · 0.90
_getTraceInfoFromScopeFunction · 0.90
getTraceContextForScopeFunction · 0.90

Calls 3

generateSpanIdFunction · 0.90
getPropagationContextMethod · 0.80

Tested by

no test coverage detected