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

Function getTraceContextForScope

packages/opentelemetry/src/trace.ts:339–352  ·  view source on GitHub ↗
(
  client: Client,
  scope: Scope,
)

Source from the content-addressed store, hash-verified

337 * We have a custom implementation here because we need an OTEL-specific way to get the span from a scope.
338 */
339export function getTraceContextForScope(
340 client: Client,
341 scope: Scope,
342): [dynamicSamplingContext: Partial<DynamicSamplingContext>, traceContext: TraceContext] {
343 const ctx = getContextFromScope(scope);
344 const span = ctx && trace.getSpan(ctx);
345
346 const traceContext = span ? spanToTraceContext(span) : getTraceContextFromScope(scope);
347
348 const dynamicSamplingContext = span
349 ? getDynamicSamplingContextFromSpan(span)
350 : getDynamicSamplingContextFromScope(client, scope);
351 return [dynamicSamplingContext, traceContext];
352}
353
354function getActiveSpanWrapper<T>(parentSpan: Span | SentrySpan | undefined | null): (callback: () => T) => T {
355 return parentSpan !== undefined

Callers 1

Calls 5

getContextFromScopeFunction · 0.90
spanToTraceContextFunction · 0.90
getTraceContextFromScopeFunction · 0.90

Tested by

no test coverage detected