Repository navigation
fix(opentelemetry): Normalize performance timestamps - #25744
MathurAditya724 wants to merge 2 commits into
Conversation
Preserve OpenTelemetry millisecond timestamps without changing direct Sentry span timing. Fixes #25743 Co-Authored-By: GPT-6 <codex@openai.com>
size-limit report 📦Compared: b359ca2 (PR test merge using develop at 84f5d12) Against: 84f5d12 (develop) · base run #63636 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 4 not successful, 61 successful. See the run.
Successful checks
|
| @@ -38,6 +38,7 @@ import { | |||
| INTERNAL_setSegmentNameSourceIfSegment, | |||
| spanIsSegment, | |||
| spanTimeInputToSeconds, | |||
There was a problem hiding this comment.
h: instead of all of this, can we not just adjust spanTimeInputToSeconds to handle this case as well? that should already be called for started spans and when calling end, so this single point should be enough to tweak I believe?
There was a problem hiding this comment.
The tricky bit is that Sentry accepts numbers in seconds, while OTel uses milliseconds, including performance.now(). Those values can overlap, so guessing in the shared helper could break existing Sentry timestamps. We could consolidate the helpers with an explicit input mode, but would still need to distinguish the two.
OpenTelemetry spans started or ended with
performance.now()now use Unix-epoch timestamps and preserve millisecond durations. Previously these numbers were interpreted as Sentry timestamps in seconds, causing Next.js client-component loading spans to appear near 1970 and inflating trace durations.Normalize numeric time inputs for OpenTelemetry-created spans while retaining the direct Sentry API's seconds-based behavior. Idle-span cancellation passes an unambiguous high-resolution timestamp so it works with either kind of descendant span.
Fixes #25743