Repository navigation
Conversation
size-limit report 📦
|
d35bfbf to
9e95d55
Compare
264fffd to
779d31b
Compare
779d31b to
8b5f7d7
Compare
| /** | ||
| * Returns `performance.now()` in milliseconds, or `undefined` if the Performance API is unavailable. | ||
| */ | ||
| export function safePerformanceNow(): number | undefined { |
There was a problem hiding this comment.
q: Should we make an oxlint rule to not use performance.now? For server runtimes it wouldn't be necessary, but for core and browser it might make sense
There was a problem hiding this comment.
For server runtimes it wouldn't be necessary
it's necessary specifically for server. The reason for the withRandomSafeContext wrapper is that NextJS cached components break when calling random functions without this special context hack.
There was a problem hiding this comment.
RE lint rule: Could make sense, but I'd do it separately. Also I think we already thought about this when we introduced withRandomSafeContext. Will check with Charly and Awad who implemented this originally.
There was a problem hiding this comment.
Oh, turns out we already have this rule: no-unsafe-random-apis. However, it's missing some syntax variations at the moment. Will open a separate PR.
logaretm
left a comment
There was a problem hiding this comment.
LGTM! I think we talked about this, it's either we get correct timings or accurate durations. So, I think this is the right decision here.
f3ec383 to
b3c446c
Compare
5489794 to
b573c7c
Compare
b573c7c to
8e8641b
Compare
1dc236f to
50ac6a9
Compare
Spans that run while the time origin is reset (e.g. after the device slept) got the drift added to their duration, which could even be negative when the wall clock jumped backwards. Now `span.end()` without a timestamp adds the `performance.now()` time since the span started to the start time, like OpenTelemetry does. Spans with an explicit start time keep using `timestampInSeconds()` for the end. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Use loose null checks when deciding whether to compute the span end time from the performance.now() duration, and move the misplaced _onSpanEnded doc comment back to its method. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
50ac6a9 to
54b7759
Compare
After Spans #23054, spans that run while the time origin is corrected (e.g. after the device slept) get the drift added to their duration. However, If the wall clock jumps backwards, the duration can even be negative. Also, adding sleep time to spans is arguably unexpected and unprecedented in comparison to OpenTelemetry.
This PR changes s
span.end()without a explicit timestamp to compute the end as start time +performance.now()time since the start, like OpenTelemetry does. Start times still usetimestampInSeconds(), so real-time started spans and spans from performance entries stay on the same timeline.Tradeoff: when a correction happens while a span runs, its end is now based on the old time origin. So children or errors recorded after the correction can appear after the span ended. Spans with an explicit start time keep using
timestampInSeconds()for the end.