From 4fdee9cad9569042f8080b8b6cf9f92c474366a2 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 9 Jan 2025 21:09:20 +0100 Subject: [PATCH] [DI] Ensure probes without a 'sampling' property is parsed correctly --- packages/dd-trace/src/debugger/devtools_client/breakpoints.js | 4 ++-- packages/dd-trace/src/debugger/devtools_client/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dd-trace/src/debugger/devtools_client/breakpoints.js b/packages/dd-trace/src/debugger/devtools_client/breakpoints.js index dd44e9bfde0..a93f587a5b4 100644 --- a/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +++ b/packages/dd-trace/src/debugger/devtools_client/breakpoints.js @@ -23,10 +23,10 @@ async function addBreakpoint (probe) { delete probe.where // Optimize for fast calculations when probe is hit - const snapshotsPerSecond = probe.sampling.snapshotsPerSecond ?? (probe.captureSnapshot + const snapshotsPerSecond = probe.sampling?.snapshotsPerSecond ?? (probe.captureSnapshot ? MAX_SNAPSHOTS_PER_SECOND_PER_PROBE : MAX_NON_SNAPSHOTS_PER_SECOND_PER_PROBE) - probe.sampling.nsBetweenSampling = BigInt(1 / snapshotsPerSecond * 1e9) + probe.nsBetweenSampling = BigInt(1 / snapshotsPerSecond * 1e9) probe.lastCaptureNs = 0n // TODO: Inbetween `await session.post('Debugger.enable')` and here, the scripts are parsed and cached. diff --git a/packages/dd-trace/src/debugger/devtools_client/index.js b/packages/dd-trace/src/debugger/devtools_client/index.js index 89c96db18c6..7fefc7d26b5 100644 --- a/packages/dd-trace/src/debugger/devtools_client/index.js +++ b/packages/dd-trace/src/debugger/devtools_client/index.js @@ -42,7 +42,7 @@ session.on('Debugger.paused', async ({ params }) => { const id = params.hitBreakpoints[i] const probe = breakpoints.get(id) - if (start - probe.lastCaptureNs < probe.sampling.nsBetweenSampling) { + if (start - probe.lastCaptureNs < probe.nsBetweenSampling) { continue }