Skip to content

Commit a3aecf6

Browse files
Lms24claude
andcommitted
ref(core): Rename performanceNowInMs to safePerformanceNow
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 6e53d97 commit a3aecf6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/core/src/tracing/sentrySpan.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import {
4343
TRACE_FLAG_NONE,
4444
TRACE_FLAG_SAMPLED,
4545
} from '../utils/spanUtils';
46-
import { performanceNowInMs, timestampInSeconds } from '../utils/time';
46+
import { safePerformanceNow, timestampInSeconds } from '../utils/time';
4747
import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext';
4848
import { logSpanEnd } from './logSpans';
4949
import { timedEventsToMeasurements } from './measurement';
@@ -105,7 +105,7 @@ export class SentrySpan implements Span {
105105
this._startTime = spanContext.startTimestamp;
106106
} else {
107107
this._startTime = timestampInSeconds();
108-
this._startPerformanceNow = performanceNowInMs();
108+
this._startPerformanceNow = safePerformanceNow();
109109
}
110110
this._links = spanContext.links;
111111

@@ -367,7 +367,7 @@ export class SentrySpan implements Span {
367367
* device slept), and it can never be negative.
368368
*/
369369
private _getEndTimeFromDuration(): number {
370-
const performanceNow = this._startPerformanceNow === undefined ? undefined : performanceNowInMs();
370+
const performanceNow = this._startPerformanceNow === undefined ? undefined : safePerformanceNow();
371371
if (performanceNow === undefined || this._startPerformanceNow === undefined) {
372372
return timestampInSeconds();
373373
}

‎packages/core/src/utils/time.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function createUnixTimestampInSecondsFunc(): () => number {
119119
/**
120120
* Returns `performance.now()` in milliseconds, or `undefined` if the Performance API is unavailable.
121121
*/
122-
export function performanceNowInMs(): number | undefined {
122+
export function safePerformanceNow(): number | undefined {
123123
const { performance } = GLOBAL_OBJ as typeof GLOBAL_OBJ & { performance?: Performance };
124124
return performance?.now ? withRandomSafeContext(() => performance.now()) : undefined;
125125
}

0 commit comments

Comments
 (0)