Skip to content

fix(sentry): correct timing calculations in performance spans#822

Merged
thostetler merged 1 commit intoadsabs:masterfrom
thostetler:fix/sentry-span-timing
Mar 10, 2026
Merged

fix(sentry): correct timing calculations in performance spans#822
thostetler merged 1 commit intoadsabs:masterfrom
thostetler:fix/sentry-span-timing

Conversation

@thostetler
Copy link
Member

performance.now() returns milliseconds relative to page load, not
epoch timestamps. The duration calculation was subtracting epoch ms
from relative ms (producing garbage), and span.end() was receiving
relative seconds instead of epoch seconds (causing Sentry to drop
the spans silently).

  • Fixed setMeasurement to use performance.now() directly (already relative to navigation start)
  • Fixed span.end() to convert relative time to epoch seconds

performance.now() returns milliseconds relative to page load, not
epoch timestamps. The duration calculation was subtracting epoch ms
from relative ms (producing garbage), and span.end() was receiving
relative seconds instead of epoch seconds (causing Sentry to drop
the spans silently).
@thostetler thostetler force-pushed the fix/sentry-span-timing branch from 2897ac7 to 1eaee69 Compare March 10, 2026 15:35
@thostetler thostetler marked this pull request as ready for review March 10, 2026 15:35
Copilot AI review requested due to automatic review settings March 10, 2026 15:35
@thostetler thostetler merged commit 4453f01 into adsabs:master Mar 10, 2026
@thostetler thostetler deleted the fix/sentry-span-timing branch March 10, 2026 15:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect Sentry performance span timing by aligning relative performance.now() values with epoch-based timestamps, preventing invalid durations and dropped spans.

Changes:

  • Update timing.results.shown measurement to use performance.now() directly (ms since navigation start).
  • Convert span end time from relative seconds to epoch seconds by offsetting with performance.timeOrigin / performance.timing.navigationStart.

You can also share your feedback on Copilot code review. Take the survey.

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