Skip to content

Commit ccc0c2c

Browse files
committed
order
1 parent 373ee88 commit ccc0c2c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ export function captureSpan(span: Span, client: Client): SerializedStreamedSpanW
6060
client.emit('processSegmentSpan', spanJSON);
6161
}
6262

63+
// Backfill span data from OTel semantic conventions when not explicitly set.
64+
// OTel-originated spans don't have sentry.op, description, etc. — the non-streamed path
65+
// infers these in the SentrySpanExporter, but streamed spans skip the exporter entirely.
66+
// Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type.
67+
// This must run before hooks and beforeSendSpan so that user callbacks can see and override inferred values.
68+
const spanKind = (span as { kind?: number }).kind;
69+
inferSpanDataFromOtelAttributes(spanJSON, spanKind);
70+
6371
// This allows hook subscribers to mutate the span JSON
6472
// This also invokes the `processSpan` hook of all integrations
6573
client.emit('processSpan', spanJSON);
@@ -70,14 +78,6 @@ export function captureSpan(span: Span, client: Client): SerializedStreamedSpanW
7078
? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)
7179
: spanJSON;
7280

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-
8181
// Backfill sentry.span.source from sentry.source. Only `sentry.span.source` is respected by Sentry.
8282
// TODO(v11): Remove this backfill once we renamed SEMANTIC_ATTRIBUTE_SENTRY_SOURCE to sentry.span.source
8383
const spanNameSource = processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];

0 commit comments

Comments
 (0)