Skip to content

Commit 79ca222

Browse files
szegediBridgeAR
andcommitted
test(profiling): stabilize Poisson sampling filter spec (#8659)
The `should cap endTime to now() if event endTime is in the future` test set `nowValue = 1000`, which is only ~10x the samplingInterval of 100. The filter's initial `nextSamplingInstant` is an exponential RV with mean 100, so P(initial > 1000) = e^-10 ≈ 4.5e-5: the while loop in filter() would skip, `currentSamplingInstant` would stay 0, and the first assertion would fail. Raise `nowValue` to 100000 (P(initial > 100000) = e^-1000 ≈ 0). The resetInterval still bounds the while loop to ~2 iterations, so the other assertions remain tight. Co-authored-by: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 3e1f5df commit 79ca222

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/dd-trace/test/profiling/profilers/poisson.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ describe('PoissonProcessSamplingFilter', () => {
131131
now,
132132
})
133133
const prevNextSamplingInstant = filter.nextSamplingInstant
134-
nowValue = 1000
134+
// nowValue must comfortably exceed the initial nextSamplingInstant, which is an
135+
// exponential RV with mean = samplingInterval = 100. P(initial > 100000) = e^-1000,
136+
// so the first assertion below is effectively never flaky. The resetInterval still
137+
// bounds the while loop in filter() to ~2 iterations, keeping the other assertions tight.
138+
nowValue = 100000
135139
const event = { startTime: 0, duration: 1e6 }
136140
filter.filter(event)
137141
assert.ok(

0 commit comments

Comments
 (0)