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

Function getOtelParentSpanId

packages/core/src/utils/spanUtils.ts:258–264  ·  view source on GitHub ↗

* In preparation for the next major of OpenTelemetry, we want to support * looking up the parent span id according to the new API * In OTel v1, the parent span id is accessed as `parentSpanId` * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`

(span: OpenTelemetrySdkTraceBaseSpan)

Source from the content-addressed store, hash-verified

256 * In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`
257 */
258function getOtelParentSpanId(span: OpenTelemetrySdkTraceBaseSpan): string | undefined {
259 return 'parentSpanId' in span
260 ? span.parentSpanId
261 : 'parentSpanContext' in span
262 ? (span.parentSpanContext as { spanId?: string } | undefined)?.spanId
263 : undefined;
264}
265
266/**
267 * Converts a {@link StreamedSpanJSON} to a {@link SerializedSpan}.

Callers 2

spanToJSONFunction · 0.85
spanToStreamedSpanJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected