Skip to content

ref(server-utils): Set error attributes on span and simplify error info extraction#21822

Open
logaretm wants to merge 1 commit into
developfrom
awad/align-error-attributes-in-tc
Open

ref(server-utils): Set error attributes on span and simplify error info extraction#21822
logaretm wants to merge 1 commit into
developfrom
awad/align-error-attributes-in-tc

Conversation

@logaretm

@logaretm logaretm commented Jun 26, 2026

Copy link
Copy Markdown
Member

When a traced operation throws or rejects, we now set error.type and sentry.status.message attributes on the span alongside the existing error status, so the error type lines up with the rest of our span conventions.

We talked about this yday, generally tracing channels allow us to observe more errors than before in some cases but these errors are not necessarily "unhandled", but we can still set the error attributes so our users can understand more about the op failure even if handled.

…butes on span

Collapse the two branches of the thrown/rejected value handler into a single
pass that derives the status message and `error.type` once, and set
`error.type` / `sentry.status.message` attributes on the span alongside the
error status. Add assertions covering Error instances, thrown primitives,
bare error-like objects, and falsy throws.
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.48 kB - -
@sentry/browser - with treeshaking flags 25.91 kB - -
@sentry/browser (incl. Tracing) 45.97 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.72 kB - -
@sentry/browser (incl. Tracing, Profiling) 50.76 kB - -
@sentry/browser (incl. Tracing, Replay) 85.22 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.81 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 89.91 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.57 kB - -
@sentry/browser (incl. Feedback) 44.66 kB - -
@sentry/browser (incl. sendFeedback) 32.26 kB - -
@sentry/browser (incl. FeedbackAsync) 37.4 kB - -
@sentry/browser (incl. Metrics) 28.54 kB - -
@sentry/browser (incl. Logs) 28.78 kB - -
@sentry/browser (incl. Metrics & Logs) 29.47 kB - -
@sentry/react 29.27 kB - -
@sentry/react (incl. Tracing) 48.28 kB - -
@sentry/vue 32.63 kB - -
@sentry/vue (incl. Tracing) 47.84 kB - -
@sentry/svelte 27.5 kB - -
CDN Bundle 29.89 kB - -
CDN Bundle (incl. Tracing) 47.89 kB - -
CDN Bundle (incl. Logs, Metrics) 31.44 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.24 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.78 kB - -
CDN Bundle (incl. Tracing, Replay) 85.4 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.45 kB - -
CDN Bundle - uncompressed 88.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.03 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.65 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.62 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.05 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.75 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.69 kB - -
@sentry/nextjs (client) 50.67 kB - -
@sentry/sveltekit (client) 46.37 kB - -
@sentry/core/server 77.54 kB - -
@sentry/core/browser 63.88 kB - -
@sentry/node-core 61.51 kB - -
@sentry/node 123.56 kB +0.07% +81 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.4 kB - -
@sentry/node - without tracing 73.61 kB - -
@sentry/aws-serverless 84.4 kB -0.01% -2 B 🔽
@sentry/cloudflare (withSentry) - minified 180.31 kB - -
@sentry/cloudflare (withSentry) 446.24 kB - -

View base workflow run

@logaretm logaretm marked this pull request as ready for review June 26, 2026 15:02
@logaretm logaretm requested a review from a team as a code owner June 26, 2026 15:02
@logaretm logaretm requested review from a team, JPeer264, Lms24, andreiborza, mydea and s1gr1d and removed request for a team and mydea June 26, 2026 15:02

@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 b802211. Configure here.

const isObject = !!error && typeof error === 'object';
const raw = isObject ? ('message' in error ? error.message : undefined) : error;

const message = raw ? String(raw) : 'unknown_error';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Empty Error message misclassified

Low Severity

getErrorInfo uses raw ? String(raw) : 'unknown_error', so when an Error has an empty message (e.g. new Error()), the span status and sentry.status.message become unknown_error instead of the empty string from .message, unlike the previous getErrorMessage logic and unlike nearby MySQL tracing-channel handling.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b802211. 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.

1 participant