Skip to content

Commit 370f263

Browse files
committed
Update spanUtils to take parent_span_id from parentSpanContext
1 parent f220141 commit 370f263

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: packages/core/src/utils/spanUtils.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import type {
1717
SpanOrigin,
1818
SpanStatus,
1919
SpanTimeInput,
20+
SpanContextData,
2021
TraceContext,
2122
} from '../types-hoist';
2223
import type { SpanLink, SpanLinkJSON } from '../types-hoist/link';
@@ -145,14 +146,15 @@ export function spanToJSON(span: Span): SpanJSON {
145146

146147
// Handle a span from @opentelemetry/sdk-base-trace's `Span` class
147148
if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
148-
const { attributes, startTime, name, endTime, parentSpanId, status, links } = span;
149+
const { attributes, startTime, name, endTime, status, links } = span;
150+
const parent_span_id = span.parentSpanContext?.spanId
149151

150152
return dropUndefinedKeys({
151153
span_id,
152154
trace_id,
153155
data: attributes,
154156
description: name,
155-
parent_span_id: parentSpanId,
157+
parent_span_id,
156158
start_timestamp: spanTimeInputToSeconds(startTime),
157159
// This is [0,0] by default in OTEL, in which case we want to interpret this as no end time
158160
timestamp: spanTimeInputToSeconds(endTime) || undefined,
@@ -185,7 +187,7 @@ export interface OpenTelemetrySdkTraceBaseSpan extends Span {
185187
name: string;
186188
status: SpanStatus;
187189
endTime: SpanTimeInput;
188-
parentSpanId?: string;
190+
parentSpanContext?: SpanContextData;
189191
links?: SpanLink[];
190192
}
191193

0 commit comments

Comments
 (0)