Skip to content

ref(core): Ensure error span status is always valid#22522

Merged
mydea merged 4 commits into
developfrom
fn/otel-span-status
Jul 24, 2026
Merged

ref(core): Ensure error span status is always valid#22522
mydea merged 4 commits into
developfrom
fn/otel-span-status

Conversation

@mydea

@mydea mydea commented Jul 23, 2026

Copy link
Copy Markdown
Member

We have some code in otel span serialization that ensures that span statuses are correct. if we remove this layer, however we can "invalid" span statuses (e.g. random error messages etc). This change ensures we always have valid span statuses everywhere, in the legacy transaction mode.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.94 kB +0.56% +155 B 🔺
@sentry/browser - with treeshaking flags 26.39 kB +0.63% +165 B 🔺
@sentry/browser (incl. Tracing) 46.41 kB +0.21% +94 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.18 kB +0.25% +117 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.21 kB +0.18% +89 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.68 kB +0.12% +96 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.33 kB +0.13% +97 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 90.4 kB +0.12% +103 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 103.06 kB +0.09% +83 B 🔺
@sentry/browser (incl. Feedback) 45.12 kB +0.36% +158 B 🔺
@sentry/browser (incl. sendFeedback) 32.74 kB +0.47% +151 B 🔺
@sentry/browser (incl. FeedbackAsync) 37.8 kB +0.45% +166 B 🔺
@sentry/browser (incl. Metrics) 29.04 kB +0.57% +162 B 🔺
@sentry/browser (incl. Logs) 29.26 kB +0.53% +152 B 🔺
@sentry/browser (incl. Metrics & Logs) 29.96 kB +0.54% +159 B 🔺
@sentry/react 29.74 kB +0.53% +155 B 🔺
@sentry/react (incl. Tracing) 48.71 kB +0.21% +102 B 🔺
@sentry/vue 33.38 kB +0.49% +162 B 🔺
@sentry/vue (incl. Tracing) 48.39 kB +0.23% +108 B 🔺
@sentry/svelte 27.96 kB +0.54% +149 B 🔺
CDN Bundle 30.27 kB +0.54% +160 B 🔺
CDN Bundle (incl. Tracing) 48.24 kB +0.21% +100 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.84 kB +0.48% +151 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 49.56 kB +0.2% +96 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 71.12 kB +0.24% +164 B 🔺
CDN Bundle (incl. Tracing, Replay) 85.81 kB +0.12% +97 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.13 kB +0.14% +119 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.59 kB +0.11% +99 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.87 kB +0.11% +93 B 🔺
CDN Bundle - uncompressed 90.09 kB +0.37% +324 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 145.16 kB +0.23% +324 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.8 kB +0.35% +324 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.14 kB +0.22% +324 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.57 kB +0.15% +324 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.4 kB +0.13% +324 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.37 kB +0.13% +324 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.1 kB +0.12% +324 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.06 kB +0.12% +324 B 🔺
@sentry/nextjs (client) 51.23 kB +0.2% +99 B 🔺
@sentry/sveltekit (client) 46.84 kB +0.19% +86 B 🔺
@sentry/core/server 80.04 kB +0.15% +117 B 🔺
@sentry/core/browser 52 kB +0.2% +102 B 🔺
@sentry/node 124.48 kB +0.07% +83 B 🔺
@sentry/node (incl. diagnostics channel injection) 168.49 kB +0.05% +80 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B - -
@sentry/node - without tracing 74.74 kB +0.12% +83 B 🔺
@sentry/aws-serverless 84.2 kB +0.09% +74 B 🔺
@sentry/cloudflare (withSentry) - minified 197.03 kB +0.22% +414 B 🔺
@sentry/cloudflare (withSentry) 484.49 kB +0.32% +1.52 kB 🔺

View base workflow run

@mydea
mydea marked this pull request as ready for review July 23, 2026 08:01
@mydea
mydea requested a review from a team as a code owner July 23, 2026 08:01
@mydea
mydea requested review from JPeer264, Lms24 and isaacs and removed request for a team July 23, 2026 08:01
Comment thread packages/core/src/tracing/spanstatus.ts
@mydea
mydea requested a review from a team as a code owner July 23, 2026 09:09
@mydea
mydea force-pushed the fn/otel-span-status branch from b5b62ef to 60f9673 Compare July 24, 2026 07:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 1 potential issue.

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 60f9673. Configure here.

} from '@sentry/core';
import type { Span, SpanAttributes } from '@sentry/core';
import { inferStatusFromAttributes, isStatusErrorMessageValid } from './utils/mapStatus';
import { inferStatusFromAttributes } from './utils/mapStatus';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreachable status normalization branch

Low Severity

applyOtelSpanStatus still tries to normalize invalid error messages for non-streaming spans, but it receives spanJSON.status from getStatusMessage, which already always returns a valid value. That makes the isStatusErrorMessageValid check and live setStatus call unreachable leftover after the core change.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 60f9673. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is fine, we apply a more in-depth normalization here, we do not look at grpc status code in core implementation etc.

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bundle size hit isn't ideal but I don't see an easy way to limit this to server runtimes only. Briefly thought about storing this on the client but then we'd need to get the client for span serialization which is also far from ideal 😅 Also, I think it could theoretically also affect the client-side.

@mydea
mydea merged commit 110f6c4 into develop Jul 24, 2026
282 checks passed
@mydea
mydea deleted the fn/otel-span-status branch July 24, 2026 08:05
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.

3 participants