Skip to content

Commit 623ad14

Browse files
committed
fix
1 parent d602203 commit 623ad14

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

  • dev-packages/node-integration-tests/suites/tracing/httpIntegration-streamed
  • packages/core/src/tracing/spans

dev-packages/node-integration-tests/suites/tracing/httpIntegration-streamed/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('httpIntegration-streamed', () => {
2121
expect(serverSpan?.is_segment).toBe(true);
2222
expect(serverSpan?.name).toBe('GET /test');
2323
expect(serverSpan?.attributes?.['sentry.source']).toEqual({ type: 'string', value: 'route' });
24+
expect(serverSpan?.attributes?.['sentry.span.source']).toEqual({ type: 'string', value: 'route' });
2425
},
2526
})
2627
.start();

packages/core/src/tracing/spans/captureSpan.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ export function captureSpan(span: Span, client: Client): SerializedStreamedSpanW
7070
? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)
7171
: spanJSON;
7272

73+
// Backfill span data from OTel semantic conventions when not explicitly set.
74+
// OTel-originated spans don't have sentry.op, description, etc. — the non-streamed path
75+
// infers these in the SentrySpanExporter, but streamed spans skip the exporter entirely.
76+
// Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.
77+
// This must run before the sentry.span.source backfill below, so that inferred sentry.source is picked up.
78+
const spanKind = (span as { kind?: number }).kind;
79+
inferSpanDataFromOtelAttributes(processedSpan, spanKind);
80+
7381
// Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.
7482
// TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source
7583
const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
@@ -81,13 +89,6 @@ export function captureSpan(span: Span, client: Client): SerializedStreamedSpanW
8189
});
8290
}
8391

84-
// Backfill span data from OTel semantic conventions when not explicitly set.
85-
// OTel-originated spans don't have sentry.op, description, etc. — the non-streamed path
86-
// infers these in the SentrySpanExporter, but streamed spans skip the exporter entirely.
87-
// Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.
88-
const spanKind = (span as { kind?: number }).kind;
89-
inferSpanDataFromOtelAttributes(processedSpan, spanKind);
90-
9192
return {
9293
...streamedSpanJsonToSerializedSpan(processedSpan),
9394
_segmentSpan: segmentSpan,

0 commit comments

Comments
 (0)