Skip to content

Commit e2e3cc0

Browse files
committed
avoid flake
1 parent eaf147e commit e2e3cc0

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • dev-packages/browser-integration-tests/suites/profiling

dev-packages/browser-integration-tests/suites/profiling/test-utils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ interface ValidateProfileOptions {
77
isChunkFormat?: boolean;
88
}
99

10+
/** Seconds — consecutive chunk timestamps can jitter slightly below float precision (see profiling flakes). */
11+
const CHUNK_SAMPLE_TIMESTAMP_EPSILON_SEC = 1e-5;
12+
1013
/**
1114
* Validates the metadata of a profile chunk envelope.
1215
* https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/
@@ -66,9 +69,9 @@ export function validateProfile(
6669
const ts = chunkProfileSample.timestamp;
6770
expect(Number.isFinite(ts)).toBe(true);
6871
expect(ts).toBeGreaterThan(0);
69-
// Monotonic non-decreasing timestamps
70-
expect(ts).toBeGreaterThanOrEqual(previousTimestamp);
71-
previousTimestamp = ts;
72+
// Monotonic non-decreasing timestamps (epsilon: jitter / IEEE754 around ~1e9 epoch seconds)
73+
expect(ts).toBeGreaterThanOrEqual(previousTimestamp - CHUNK_SAMPLE_TIMESTAMP_EPSILON_SEC);
74+
previousTimestamp = Math.max(previousTimestamp, ts);
7275
} else {
7376
// Legacy format uses elapsed_since_start_ns as a string
7477
const legacyProfileSample = sample as ThreadCpuProfile['samples'][number];

0 commit comments

Comments
 (0)