Commit 5abf807
authored
fix(debugger): initialize lastCaptureNs to ensure first probe hit is captured (#7042)
When a probe is added with any sampling rate, the first probe hit could
be incorrectly skipped if it occurred within the sampling interval after
process start.
This happened because `lastCaptureNs` was initialized to `0n`, causing
the sampling check
`start - probe.lastCaptureNs < probe.nsBetweenSampling` to evaluate to
true when the process had been running for less time than the sampling
interval.
For example:
- At 10 samples/sec: first hit skipped if within first 100ms
- At 5 samples/sec: first hit skipped if within first 200ms
- At 1 sample/sec: first hit skipped if within first 1 second
- At 0.5 samples/sec: first hit skipped if within first 2 seconds
Fix by initializing `lastCaptureNs` to
`BigInt(Number.MIN_SAFE_INTEGER)`, ensuring the first probe hit always
passes the sampling check regardless of when it occurs.1 parent d23ef75 commit 5abf807
File tree
2 files changed
+28
-3
lines changed- packages/dd-trace
- src/debugger/devtools_client
- test/debugger/devtools_client
2 files changed
+28
-3
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
114 | 137 | | |
115 | 138 | | |
116 | 139 | | |
| |||
486 | 509 | | |
487 | 510 | | |
488 | 511 | | |
489 | | - | |
| 512 | + | |
490 | 513 | | |
491 | 514 | | |
492 | 515 | | |
493 | 516 | | |
494 | | - | |
| 517 | + | |
| 518 | + | |
495 | 519 | | |
496 | 520 | | |
0 commit comments