Repository navigation
Conversation
📊 Type Coverage Diff✅ no issues found |
| if (options.preferences?.clock_drift_correction) { | ||
| TraceTree.ApplyClockDriftCorrection(tree.root); | ||
| } | ||
|
|
There was a problem hiding this comment.
Clock drift runs before pageload swap
Medium Severity
Correction is applied before the pageload/server-handler swap, and shiftSubtree moves every descendant of the server span. When an http.client → http.server → pageload tree is still in its pre-swap shape, the browser pageload (and its children) inherit the server's offset even though they use the client clock. Toggling correction later runs on the already-swapped tree and does not shift pageload, so loading with the preference on and turning it on in the UI can produce different waterfalls.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2785270. Configure here.
2785270 to
0c96acc
Compare
| issue, | ||
| node_space, | ||
| props.node.clockDriftOffsetMs | ||
| ); |
There was a problem hiding this comment.
Occurrence patterns ignore clock drift offset
Medium Severity
Performance-issue hatch patterns still position from the occurrence's raw timestamp, while the span bar now uses shifted space. After a clock-drift move, that timestamp falls outside the bar and is clamped to the start or end, so the pattern no longer lines up with the issue. Issue icons were updated to add clockDriftOffsetMs; these patterns were not.
Reviewed by Cursor Bugbot for commit 0c96acc. Configure here.
Client devices often have clocks that disagree with the server's, so server spans can start before or end after the client request that made them. Relay only corrects drift of 55 minutes or more, so smaller drift reaches the waterfall uncorrected and makes traces hard to read. Shift each misaligned server subtree into its client span by the smallest amount that fits. Requests crossing into a new segment are detected as client/server pairs, and pairs are grouped by the client's segment, which shares one clock. Within a segment, only requests that agree with the majority are corrected, and shifts below 10ms are ignored. Only node spaces change, recorded timestamps stay intact. The correction is a trace preference (on by default) that can be toggled off. Corrected spans show a clock icon in their duration label and a "Shifted" tag in the drawer, both explaining the adjustment on hover. Co-Authored-By: Claude <noreply@anthropic.com>
Only organizations with the trace-waterfall-clock-drift-correction flag can use clock drift correction, and it is off by default. Without the flag, the correction is never applied and its toggle is hidden, even if it was stored as turned on. Also explain the shift on hover over the whole duration label of every shifted span, not only the icon, and reword the tooltips. Center duration labels and the icon on the row by layout instead of font metrics, so they line up the same at every pixel density. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Autogroup nodes did not take the offset of the spans they wrap, so issues on grouped spans in a shifted subtree were drawn at their recorded time. Also simplify the correction code: reuse formatTraceDuration, drop the unused clientNode, the static TraceTree wrappers and the restore count, narrow node types without casts, and fix two misplaced doc comments. Co-Authored-By: Claude <noreply@anthropic.com>
The correction object on a node only carried the offset of its own shift, which nothing outside of tests read: every consumer only checked whether it was set. The total offset already lives in clockDriftOffsetMs, so a boolean marks the root of a moved subtree instead. Co-Authored-By: Claude <noreply@anthropic.com>
0c96acc to
92b761c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 92b761c. Configure here.
| // off everywhere, also if it was stored while the organization had the feature. | ||
| const initialPreferences = hasClockDriftCorrectionFeature(organization) | ||
| ? props.initialPreferences | ||
| : {...props.initialPreferences, clock_drift_correction: false}; |
There was a problem hiding this comment.
Flag off overwrites stored preference
Medium Severity
When the clock-drift feature flag is off, TraceStateProvider forces clock_drift_correction to false in reducer state, and the existing persist effect then writes that value to localStorage. Visiting an org without the flag, or a temporary flag-off during rollout, permanently clears a previously enabled preference for every org that shares that storage key.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 92b761c. Configure here.


This PR adds clock drift correction to the trace waterfall, gated behind the
trace-waterfall-clock-drift-correctionflag.When the clocks of a client and a server are not in sync, a server span can show up before or after the client request that caused it. This happens often on client-side apps, given user devices are corrected via NTP, users have set clocks manually, etc. With getsentry/sentry-javascript#23054 in the JS SDK, we now more often adjust our telemetry timestamps to the users' wall clock (it's the only somewhat reliable clock in browsers), which likely increased the amount of out-of-sync client and server span trees.
The correction shifts the server subtree into the client span that made the request. It can be toggled in the trace preferences and is off by default. Shifted spans show a clock icon on the subtree root, and their duration label and the details panel explain the shift on hover. The criteria for applying the clock drift are:
http.clientfollowed by ahttp.serverchild segmentClock drift makes traces across services hard to read, and the correction fixes the most common case. We want to try it with a few internal orgs first. This also centers duration labels on the span bar by layout instead of font metrics. That moves all labels by about 1px but keeps the icon aligned at every pixel density.
Screenshots
Clock drift correction toggle (off)
Clock drift correction toggle (on)
Raw waterfall (note the 2 min. drift)
Corrected waterfall
Waterfall tooltip
Detail panel tooltip
Testing
Some traces if anyone wants to check out the preview:
Flag: #132009. Rollout: getsentry/sentry-options-automator#10726.
🤖 Generated with Claude Code