File tree Expand file tree Collapse file tree
dev-packages/browser-integration-tests/suites/profiling Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ] ;
You can’t perform that action at this time.
0 commit comments