Skip to content

feat(core): Backfill otel attributes on streamed spans#20439

Open
chargome wants to merge 9 commits intodevelopfrom
cg/streamed-span-op-attribute
Open

feat(core): Backfill otel attributes on streamed spans#20439
chargome wants to merge 9 commits intodevelopfrom
cg/streamed-span-op-attribute

Conversation

@chargome
Copy link
Copy Markdown
Member

@chargome chargome commented Apr 22, 2026

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

closes #20425

@chargome chargome self-assigned this Apr 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.96 kB - -
@sentry/browser - with treeshaking flags 24.44 kB - -
@sentry/browser (incl. Tracing) 43.89 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 45.83 kB +0.66% +300 B 🔺
@sentry/browser (incl. Tracing, Profiling) 48.84 kB - -
@sentry/browser (incl. Tracing, Replay) 83.09 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.59 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 87.77 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.38 kB - -
@sentry/browser (incl. Feedback) 43.18 kB - -
@sentry/browser (incl. sendFeedback) 30.77 kB - -
@sentry/browser (incl. FeedbackAsync) 35.93 kB - -
@sentry/browser (incl. Metrics) 27.25 kB - -
@sentry/browser (incl. Logs) 27.38 kB - -
@sentry/browser (incl. Metrics & Logs) 28.07 kB - -
@sentry/react 27.72 kB - -
@sentry/react (incl. Tracing) 46.13 kB - -
@sentry/vue 30.81 kB - -
@sentry/vue (incl. Tracing) 45.71 kB - -
@sentry/svelte 25.98 kB - -
CDN Bundle 28.66 kB - -
CDN Bundle (incl. Tracing) 46.4 kB +0.63% +287 B 🔺
CDN Bundle (incl. Logs, Metrics) 30.03 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 47.46 kB +0.63% +297 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.99 kB - -
CDN Bundle (incl. Tracing, Replay) 83.49 kB +0.36% +298 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 84.51 kB +0.36% +299 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 89.3 kB +0.34% +296 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.36 kB +0.33% +297 B 🔺
CDN Bundle - uncompressed 83.91 kB - -
CDN Bundle (incl. Tracing) - uncompressed 138.65 kB +0.61% +830 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 88.06 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 142.06 kB +0.59% +830 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 211.63 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 256.09 kB +0.33% +830 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 259.49 kB +0.33% +830 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 269.79 kB +0.31% +830 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 273.18 kB +0.31% +830 B 🔺
@sentry/nextjs (client) 48.62 kB - -
@sentry/sveltekit (client) 44.33 kB - -
@sentry/node-core 58.73 kB +0.36% +209 B 🔺
@sentry/node 176.1 kB +0.16% +273 B 🔺
@sentry/node - without tracing 98.56 kB +0.25% +244 B 🔺
@sentry/aws-serverless 115.75 kB +0.21% +232 B 🔺

View base workflow run

@chargome chargome marked this pull request as ready for review April 22, 2026 09:07
Comment thread packages/opentelemetry/test/sampler.test.ts Outdated
@chargome chargome marked this pull request as draft April 22, 2026 14:25
@chargome
Copy link
Copy Markdown
Member Author

will find another way of doing this

@chargome chargome force-pushed the cg/streamed-span-op-attribute branch from 73ad7b6 to ae0c9db Compare April 22, 2026 14:58
@chargome chargome changed the title feat(opentelemetry): Propagate inferred sentry.op onto streamed span attributes feat(core): Backfill sentry.op on streamed spans from OTel semantic conventions Apr 22, 2026
@chargome chargome changed the title feat(core): Backfill sentry.op on streamed spans from OTel semantic conventions feat(core): Backfill sentry.op on streamed spans Apr 22, 2026
@JPeer264 JPeer264 removed their request for review April 22, 2026 16:17
@chargome chargome changed the title feat(core): Backfill sentry.op on streamed spans feat(core): Backfill otel attrbiutes on streamed spans Apr 24, 2026
@chargome chargome changed the title feat(core): Backfill otel attrbiutes on streamed spans feat(core): Backfill otel attributes on streamed spans Apr 24, 2026
@chargome chargome force-pushed the cg/streamed-span-op-attribute branch from 0c2d529 to d602203 Compare April 24, 2026 13:19
@chargome chargome marked this pull request as ready for review April 24, 2026 13:37
Comment thread packages/core/src/tracing/spans/captureSpan.ts
Comment thread packages/core/src/tracing/spans/captureSpan.ts
Comment thread packages/core/src/tracing/spans/captureSpan.ts
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c2e1043. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backfill sentry.op for streamed client.http spans

1 participant