fix(sentry): discard timed-out onboarding traces instead of sending fake ~5-min durations#33318
fix(sentry): discard timed-out onboarding traces instead of sending fake ~5-min durations#33318smgv wants to merge 4 commits into
Conversation
…ake ~5-min durations When a span is still open after TRACES_CLEANUP_INTERVAL (5 min), the cleanup timeout now marks it with SpanStatus ERROR / deadline_exceeded and sets `trace.timed_out = true` before calling end(). The `excludeEvents` beforeSendTransaction hook drops any event carrying that flag, so artificially-clamped spans (p50 ≈ 300,014 ms for "Onboarding - Overall Journey") are never sent to Sentry. Legitimate long-but-real spans are unaffected because the drop is keyed strictly on the flag, not on duration. Co-authored-by: Cursor <cursoragent@cursor.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
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, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 971548d. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Both changes are purely observability/monitoring infrastructure changes:
The accompanying test files ( These changes cannot break any E2E test flows and have no performance impact. Zero E2E tags and zero performance tags are appropriate. Performance Test Selection: |
🧪 Flaky unit test detectionRun history flaky detectionHistorical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow. Failures / runs sampled per window:
AI-detected flaky patterns
|
|




Description
When a span is still open after TRACES_CLEANUP_INTERVAL (5 min), the cleanup timeout now marks it with SpanStatus ERROR / deadline_exceeded and sets
trace.timed_out = truebefore calling end(). TheexcludeEventsbeforeSendTransaction hook drops any event carrying that flag, so artificially-clamped spans (p50 ≈ 300,014 ms for "Onboarding - Overall Journey") are never sent to Sentry. Legitimate long-but-real spans are unaffected because the drop is keyed strictly on the flag, not on duration.JIRA Link: https://consensyssoftware.atlassian.net/browse/TO-898
Changelog
CHANGELOG entry: discard timed-out onboarding traces instead of sending fake ~5-min durations
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Nothing to "see" in Sentry
The fix works by dropping the bad trace before it's ever sent to Sentry. A dropped trace leaves no record — so a working fix shows up as the bad ~5-minute spans disappearing, not as a new event. There is nothing to screenshot; success = absence.
The only Sentry signal is therefore negative and only meaningful at scale: after release, Onboarding - Overall Journey p50 should drop away from ~300,000 ms. That's the post-ship confirmation (production dashboard), not something visible from one test run.
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Observability-only filtering keyed on an explicit timeout flag; no app logic, auth, or data paths change beyond what Sentry receives.
Overview
Fixes inflated onboarding journey durations (~5 min p50) when spans are never closed by not sending those transactions to Sentry.
When
TRACES_CLEANUP_INTERVALfires on an still-open manual span, cleanup now sets span status todeadline_exceededand attributetrace.timed_out: truebefore ending the span.excludeEvents(beforeSendTransaction) returnsnullfor any transaction whose trace context hastrace.timed_out === true, same pattern as dropping Route Change. Real spans that end normally never get the flag and are unchanged.Unit tests cover timeout cleanup marking the span and
excludeEventsdrop vs pass-through.Reviewed by Cursor Bugbot for commit dee892a. Bugbot is set up for automated code reviews on this repo. Configure here.