Skip to content

feat(core)!: Return StreamedSpanJSON from spanToJSON - #22968

Draft
Lms24 wants to merge 4 commits into
developfrom
lms/ref-spanToJson
Draft

feat(core)!: Return StreamedSpanJSON from spanToJSON#22968
Lms24 wants to merge 4 commits into
developfrom
lms/ref-spanToJson

Conversation

@Lms24

@Lms24 Lms24 commented Aug 3, 2026

Copy link
Copy Markdown
Member

This PR:

  • (breaking) changes the return type of spanToJSON from SpanJSON to StreamedSpanJSON
  • (breaking) removes spanToStreamedSpanJSON (which IMHO is fine, it was only added for opt-in span streaming and never publicly documented)
  • adds spanToStaticSpanJSON for any transaction code paths
  • adjusts every internal spanToJSON usage to work with the new return type

Because we should also use the new span format in our SDK, this PR also adjusts every usage of spanToJSON to the new format.

Comment thread packages/browser/src/tracing/browserTracingIntegration.ts Outdated
Comment thread packages/react/src/profiler.tsx Outdated
Comment thread packages/solid/src/solidrouter.ts Outdated
Comment thread packages/core/src/utils/spanUtils.ts
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 30.36 kB +0.02% +4 B 🔺
@sentry/browser - with treeshaking flags 28.53 kB +0.04% +10 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 26.86 kB +0.03% +8 B 🔺
@sentry/browser (incl. Tracing) 48.64 kB +0.06% +25 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.65 kB +0.06% +29 B 🔺
@sentry/browser (incl. Tracing, Profiling) 53.48 kB +0.04% +19 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.06 kB +0.03% +19 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.48 kB +0.03% +22 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.79 kB +0.03% +25 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.48 kB +0.03% +24 B 🔺
@sentry/browser (incl. Feedback) 47.69 kB +0.01% +1 B 🔺
@sentry/browser (incl. sendFeedback) 35.18 kB +0.02% +4 B 🔺
@sentry/browser (incl. FeedbackAsync) 40.34 kB +0.01% +3 B 🔺
@sentry/browser (incl. Metrics) 31.43 kB +0.02% +5 B 🔺
@sentry/browser (incl. Logs) 31.66 kB +0.03% +7 B 🔺
@sentry/browser (incl. Metrics & Logs) 32.35 kB +0.03% +8 B 🔺
@sentry/react 32.15 kB +0.03% +7 B 🔺
@sentry/react (incl. Tracing) 50.83 kB +0.03% +11 B 🔺
@sentry/vue 35.45 kB +0.01% +2 B 🔺
@sentry/vue (incl. Tracing) 50.6 kB +0.04% +16 B 🔺
@sentry/svelte 30.38 kB +0.02% +4 B 🔺
CDN Bundle 31.61 kB +0.02% +6 B 🔺
CDN Bundle (incl. Tracing) 48.95 kB +0.07% +32 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.85 kB +0.02% +4 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 50.91 kB +0.05% +23 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.38 kB +0.01% +4 B 🔺
CDN Bundle (incl. Tracing, Replay) 86.51 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.42 kB +0.03% +18 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.22 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.2 kB +0.02% +14 B 🔺
CDN Bundle - uncompressed 93.98 kB +0.04% +34 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 147.04 kB +0.08% +116 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.45 kB +0.04% +34 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.89 kB +0.08% +116 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.39 kB +0.02% +44 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.3 kB +0.05% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.14 kB +0.05% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280 kB +0.05% +126 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.83 kB +0.05% +126 B 🔺
@sentry/nextjs (client) 53.4 kB +0.04% +20 B 🔺
@sentry/sveltekit (client) 49.05 kB +0.05% +22 B 🔺
@sentry/core/server 65.61 kB +0.03% +15 B 🔺
@sentry/core/browser 51.93 kB +0.03% +12 B 🔺
@sentry/node 118.47 kB +0.02% +14 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 82.58 kB +0.02% +14 B 🔺
@sentry/aws-serverless 91.95 kB +0.02% +10 B 🔺
@sentry/cloudflare (withSentry) - minified 214.73 kB +0.02% +29 B 🔺
@sentry/cloudflare (withSentry) 530.46 kB +0.05% +226 B 🔺

View base workflow run

Comment thread packages/core/src/utils/spanUtils.ts Outdated
@Lms24
Lms24 force-pushed the lms/ref-spanToJson branch 2 times, most recently from 598470e to 0c779fc Compare August 10, 2026 11:48
Comment thread packages/core/src/utils/spanUtils.ts
@Lms24
Lms24 force-pushed the lms/ref-spanToJson branch from 0c779fc to d37dc10 Compare August 10, 2026 12:07
Comment thread packages/core/src/utils/spanUtils.ts
Lms24 added 4 commits August 10, 2026 14:50
`spanToJSON` now returns the intermediate `StreamedSpanJSON` representation
instead of the legacy `SpanJSON`. The previous behaviour is still available as
`spanToStaticSpanJSON`, and the old `spanToStreamedSpanJSON` export is gone
(it *is* `spanToJSON` now).

Field mapping for call sites: `description` -> `name`, `data` -> `attributes`,
`timestamp` -> `end_timestamp`, and `op`/`origin` move into `attributes` under
`sentry.op` / `sentry.origin`. `status` is narrowed to `'ok' | 'error'`.

`end_timestamp` is optional on `StreamedSpanJSON` and only required on
`SerializedStreamedSpan`, so the guarantee we actually care about — every span
we *send* has an end timestamp — is enforced at the single serialization
boundary (`streamedSpanJsonToSerializedSpan`) rather than baked into every span
representation. That keeps `end_timestamp` usable as the "has this span ended?"
signal it already was, so the open-span checks in `browserTracingIntegration`,
`idleSpan` and the React Router instrumentation stay simple field reads.
@Lms24
Lms24 force-pushed the lms/ref-spanToJson branch from b914bde to 3e9e966 Compare August 10, 2026 12:50

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

Comment thread MIGRATION.md

The `spanToJSON` helper previously returned a `SpanJSON` object. In v11, the return type was changed to `StreamedSpanJSON`, meaning the object shape is now the [same as in `beforeSendSpan`](#beforeSendSpan-receives-the-streamed-span-format).

If you're [opting out of span streaming](#opting-out-of-span-streaming), you can replace your `spanToJSON` calls with `spanToStaticSpanJSON`, which still returns the static `SpanJSON` object format.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing streamed helper migration note

Low Severity

This PR removes the publicly exported spanToStreamedSpanJSON helper, but the migration section only documents the spanToJSON return-type change and the new spanToStaticSpanJSON API. Callers of the removed export do not get an explicit migration path. Flagged because the review rules call out public API removals and signature changes without proper notices.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

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