fix(core): Inject replayId into trace context for buffer mode errors#5754
Draft
romtsn wants to merge 2 commits into
Draft
fix(core): Inject replayId into trace context for buffer mode errors#5754romtsn wants to merge 2 commits into
romtsn wants to merge 2 commits into
Conversation
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 94ec28b | 317.49 ms | 407.84 ms | 90.35 ms |
| 39e4c55 | 352.43 ms | 446.94 ms | 94.51 ms |
| 048e40b | 322.47 ms | 362.69 ms | 40.22 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 94ec28b | 0 B | 0 B | 0 B |
| 39e4c55 | 0 B | 0 B | 0 B |
| 048e40b | 0 B | 0 B | 0 B |
Previous results on branch: rz/fix/replay-error-linkage
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 01678a6 | 315.83 ms | 347.92 ms | 32.09 ms |
| e6285ac | 315.38 ms | 353.88 ms | 38.50 ms |
| 9fbe087 | 391.26 ms | 480.70 ms | 89.44 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 01678a6 | 0 B | 0 B | 0 B |
| e6285ac | 0 B | 0 B | 0 B |
| 9fbe087 | 0 B | 0 B | 0 B |
In buffer mode, the scope's replayId is empty until captureReplay() is called. The transaction's baggage is frozen before that, so the DSC in the envelope header has no replay_id — breaking error-to-replay linkage. After captureReplay() sets the replayId on scope, force-set it on the transaction's frozen baggage via Baggage.forceSetReplayId() so the envelope header carries the correct replay_id in the DSC. This matches the JS SDK's approach of updating the DSC after buffer-to- session conversion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43dceab to
8c8db4b
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e63a32e to
6f89328
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
In buffer mode, the scope's
replayIdis intentionally empty untilcaptureReplay()is called (to avoid tagging events with a replay that may never be sent). However, the event's trace context is built from the active transaction's frozen baggage, which was frozen beforecaptureReplay()set thereplayId. This means error events that trigger a buffer replay flush are never linked to the replay in the envelope header.After
captureReplay()runs, we now check if the scope has areplayIdthat the trace context is missing and inject it viaTraceContext.withReplayId().💡 Motivation and Context
Error events that trigger buffer-mode replay capture were not linked to the resulting replay, making it impossible to navigate from the error to its replay in the Sentry UI.
💚 How did you test it?
SentryClientTestsuite passes (261 tests)📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps