Skip to content

fix(effect): Convert Effect span times to the Sentry clock - #24972

Open
Lms24 wants to merge 1 commit into
lms/fix-core-span-end-monotonic-durationfrom
lms/fix-effect-tracer-clock-drift
Open

Lms24 wants to merge 1 commit into
lms/fix-core-span-end-monotonic-durationfrom
lms/fix-effect-tracer-clock-drift

Conversation

@Lms24

@Lms24 Lms24 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Effect spans used Effect's own clock (a fixed origin plus a monotonic clock) for their start, end and event times. #23054 makes Sentry correct its clock for drift (e.g. after the device slept), so Effect spans could end up shifted by the drift relative to the Sentry spans around them. With this PR, an Effect span now starts on Sentry's clock, and its end and event times are converted by their offset from the span's start. This is the same per-span offset that OpenTelemetry's SDK uses. We also do this for our spans now, see #24903 for details.

The PR keeps Effect's durations and any end time passed explicitly via span.end(time, exit). With withTracerTiming(false), Effect passes 0, and we now use Sentry's clock instead of setting 1970 timestamps.

@Lms24
Lms24 added this pull request to stack #24904 October 2, 2026 09:44
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.63 kB +0.39% +115 B 🔺
@sentry/browser - with treeshaking flags 27.78 kB +0.38% +103 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 27.68 kB +0.4% +109 B 🔺
@sentry/browser (incl. Tracing) 51.67 kB +0.44% +226 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 51.7 kB +0.46% +235 B 🔺
@sentry/browser (incl. Tracing, Profiling) 54.65 kB +0.35% +190 B 🔺
@sentry/browser (incl. Tracing, Replay) 91.28 kB +0.26% +235 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.22 kB +0.25% +196 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 95.98 kB +0.25% +238 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 108.92 kB +0.2% +216 B 🔺
@sentry/browser (incl. Feedback) 47.13 kB +0.2% +92 B 🔺
@sentry/browser (incl. sendFeedback) 34.69 kB +0.34% +117 B 🔺
@sentry/browser (incl. FeedbackAsync) 39.79 kB +0.28% +111 B 🔺
@sentry/browser (incl. Metrics) 30.66 kB +0.39% +118 B 🔺
@sentry/browser (incl. Logs) 30.94 kB +0.37% +111 B 🔺
@sentry/browser (incl. Metrics & Logs) 31.6 kB +0.38% +117 B 🔺
@sentry/react 31.46 kB +0.31% +96 B 🔺
@sentry/react (incl. Tracing) 54.05 kB +0.46% +246 B 🔺
@sentry/vue 37.72 kB +0.57% +213 B 🔺
@sentry/vue (incl. Tracing) 54.59 kB +0.49% +263 B 🔺
@sentry/svelte 29.65 kB +0.36% +105 B 🔺
@sentry/remix (Remix 3 client bundle) 55.97 kB +0.37% +201 B 🔺
CDN Bundle 31.33 kB +0.36% +111 B 🔺
CDN Bundle (incl. Tracing) 52.18 kB +0.39% +201 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.53 kB +0.21% +68 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 54.12 kB +0.39% +208 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.28 kB +0.1% +72 B 🔺
CDN Bundle (incl. Tracing, Replay) 89.72 kB +0.18% +159 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.68 kB +0.17% +149 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 95.88 kB +0.18% +163 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.88 kB +0.18% +170 B 🔺
CDN Bundle - uncompressed 92.4 kB +0.28% +252 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 154.96 kB +0.3% +462 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.87 kB +0.16% +157 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 160.91 kB +0.29% +462 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 228.4 kB +0.06% +118 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 274.67 kB +0.17% +442 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 280.61 kB +0.16% +442 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 288.37 kB +0.16% +442 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 294.3 kB +0.16% +442 B 🔺
@sentry/nextjs (client) 56.54 kB +0.41% +226 B 🔺
@sentry/sveltekit (client) 52.08 kB +0.4% +206 B 🔺
@sentry/core/server 40.79 kB +0.5% +199 B 🔺
@sentry/core/browser 13.82 kB +1.41% +191 B 🔺
@sentry/node 144.93 kB +0.14% +199 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.32 kB +0.14% +113 B 🔺
@sentry/node - without tracing 93.54 kB +0.28% +252 B 🔺
@sentry/node - without channel injection 123.2 kB +0.2% +240 B 🔺
@sentry/aws-serverless 101.78 kB +0.22% +215 B 🔺
@sentry/cloudflare (withSentry) - minified 209.29 kB +0.33% +676 B 🔺
@sentry/cloudflare (withSentry) 519.54 kB +0.42% +2.14 kB 🔺

View base workflow run

@Lms24
Lms24 force-pushed the lms/fix-effect-tracer-clock-drift branch 3 times, most recently from db2102a to 1d4abf9 Compare October 2, 2026 10:05
@Lms24 Lms24 self-assigned this Oct 2, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 1d4abf9. Configure here.

Comment thread packages/effect/src/tracer.ts
@Lms24
Lms24 force-pushed the lms/fix-effect-tracer-clock-drift branch from 1d4abf9 to 29752e0 Compare October 2, 2026 10:18
@Lms24
Lms24 marked this pull request as ready for review October 2, 2026 11:53
@Lms24
Lms24 requested a review from a team as a code owner October 2, 2026 11:53
@Lms24
Lms24 requested review from JPeer264, chargome and nicohrubec and removed request for a team October 2, 2026 11:53
Effect timestamps come from its own clock, a fixed origin plus a monotonic
clock, which does not correct for clock drift (e.g. after the device slept).
Sentry now does, so Effect spans could end up offset from the Sentry spans
around them. Start Effect spans on the Sentry clock and convert end and event
times by their offset from the span start. This keeps Effect durations and
explicitly passed end times. If tracer timing is disabled, Effect passes 0 and
we use the Sentry clock instead of producing 1970 timestamps.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the lms/fix-effect-tracer-clock-drift branch from 29752e0 to fa51d1f Compare October 2, 2026 14:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants