feat(core)!: Return StreamedSpanJSON from spanToJSON - #22968
Conversation
size-limit report 📦
|
598470e to
0c779fc
Compare
0c779fc to
d37dc10
Compare
`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.
b914bde to
3e9e966
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
|
|
||
| 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. |
There was a problem hiding this comment.
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)
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 3e9e966. Configure here.


This PR:
spanToJSONfromSpanJSONtoStreamedSpanJSONspanToStreamedSpanJSON(which IMHO is fine, it was only added for opt-in span streaming and never publicly documented)spanToStaticSpanJSONfor any transaction code pathsspanToJSONusage to work with the new return typeBecause we should also use the new span format in our SDK, this PR also adjusts every usage of
spanToJSONto the new format.