feat(core): Backfill otel attributes on streamed spans#20439
feat(core): Backfill otel attributes on streamed spans#20439
Conversation
size-limit report 📦
|
|
will find another way of doing this |
73ad7b6 to
ae0c9db
Compare
sentry.op onto streamed span attributessentry.op on streamed spans
sentry.op on streamed spans0c2d529 to
d602203
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c2e1043. Configure here.
| attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] === 'custom' | ||
| ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Custom span names ignored in streaming path
High Severity
When SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME is detected, both inferHttpSpanData and inferDbSpanData return early without applying the user's custom name to spanJSON.name. The SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME attribute exists precisely because OTel instrumentation can overwrite user-set span names via span.updateName(). The OTel exporter's equivalent code (descriptionForHttpMethod/descriptionForDbSystem) reads this attribute and uses it as the span description. The new streaming code treats it as "don't touch the name" rather than "apply this stored name," causing user-set names (via updateSpanName) to be silently lost when OTel later overwrites them.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c2e1043. Configure here.
| // Access `kind` via duck-typing — OTel span objects have this property but it's not on Sentry's Span type. | ||
| // This must run before hooks and beforeSendSpan so that user callbacks can see and override inferred values. | ||
| const spanKind = (span as { kind?: number }).kind; | ||
| inferSpanDataFromOtelAttributes(spanJSON, spanKind); |
There was a problem hiding this comment.
Segment name attribute stale after name inference
Medium Severity
applyCommonSpanAttributes sets sentry.segment.name from serializedSegmentSpan.name (the original OTel name) at line 116 before inferSpanDataFromOtelAttributes runs. When inference later updates spanJSON.name (e.g., from "GET" to "GET /test"), the sentry.segment.name attribute remains stale because safeSetSpanJSONAttributes won't overwrite existing keys. For segment spans, this creates a mismatch between name and sentry.segment.name.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c2e1043. Configure here.


The streaming path skips the
SentrySpanExporter, which is why we backfill span data (sentry.op,name,sentry.source) incaptureSpannow. Some of the inference logic is duplicated from the otel package — which we can likely drop once we move away from otel.closes #20425