Repository navigation
Conversation
The transaction-event/span-JSON round trip in processBeforeSend did not carry contexts.trace.links, so setting beforeSendSpan (even an identity callback) dropped the root span's links, including the previous_trace link, from every transaction. Carry links through convertTransactionEventToSpanJson and convertSpanJsonToTransactionEvent. Fixes getsentry#25545
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 65b319a. Configure here.
logaretm
left a comment
There was a problem hiding this comment.
Many thanks! Just a minor change, we need to assert the result. Happy to approve once that's done.
| [SENTRY_EXCLUSIVE_TIME]: 123.45, | ||
| other: 'value', | ||
| }, | ||
| links: [ |
There was a problem hiding this comment.
These assertions cover the converters, but the links actually got lost in the merge(event, ...) step in processBeforeSend.
Could you also assert contexts.trace.links on the sent transaction in client.test.ts?

Fixes #25545
Problem
Setting
beforeSendSpan— even an identity callback(span) => span— drops the root span'scontexts.trace.linksfrom every transaction, so theprevious_tracelink is lost and the trace view no longer links to the previous trace.In
processBeforeSend, the root span goes throughbeforeSendSpan(convertTransactionEventToSpanJson(event))and the result is merged back withmerge(event, convertSpanJsonToTransactionEvent(result)). The two converters inpackages/core/src/utils/transactionEvent.tsnever copiedlinks, andmerge(default depth 2) replacescontexts.tracewhole, so the links set byspanToTransactionTraceContextare discarded. Thanks to @arobison for the detailed root-cause trace in the issue.Fix
Carry
linksthrough both conversions.TraceContext.linksandSpanJSON.linksare bothSpanLinkJSON[], so this is a direct pass-through.Tests
Extended the existing
transactionEvent.test.tsround-trip cases (convertTransactionEventToSpanJsonandconvertSpanJsonToTransactionEvent) to assertlinks(including aprevious_tracelink) survive.Verification (local):
Ran in
packages/corewith Node 22.12 / vitest 4.1.11.