Skip to content

Commit 694b67a

Browse files
committed
[DI] Record thread paused telemetry when breakpoint is hit
The target thread is paused for some amount of time when ever a breakpoint is hit. Record the amount of time in milliseconds.
1 parent 4f00bbe commit 694b67a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

packages/dd-trace/src/debugger/devtools_client/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { getLocalStateForCallFrame } = require('./snapshot')
77
const send = require('./send')
88
const { getStackFromCallFrames } = require('./state')
99
const { ackEmitting, ackError } = require('./status')
10+
const { threadPausedMsMetric } = require('./telemetry')
1011
const { parentThreadId } = require('./config')
1112
const { MAX_SNAPSHOTS_PER_SECOND_GLOBALLY } = require('./defaults')
1213
const log = require('../../log')
@@ -101,12 +102,10 @@ session.on('Debugger.paused', async ({ params }) => {
101102
}
102103

103104
await session.post('Debugger.resume')
104-
const diff = process.hrtime.bigint() - start // TODO: Recored as telemetry (DEBUG-2858)
105105

106-
log.debug(
107-
'[debugger:devtools_client] Finished processing breakpoints - main thread paused for: %d ms',
108-
Number(diff) / 1000000
109-
)
106+
const diff = Number(process.hrtime.bigint() - start) / 1_000_000
107+
log.debug('[debugger:devtools_client] Finished processing breakpoints - instrumented thread paused for: %d ms', diff)
108+
threadPausedMsMetric(diff)
110109

111110
// Due to the highly optimized algorithm above, the `probes` array might have gaps
112111
probes = probes.filter((probe) => !!probe)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict'
2+
3+
const telemetryMetrics = require('../../telemetry/metrics')
4+
5+
const debuggerNamespace = telemetryMetrics.manager.namespace('debugger')
6+
const threadPausedDistribution = debuggerNamespace.distribution('thread_paused.ms', [])
7+
8+
module.exports = {
9+
threadPausedMsMetric (ms) {
10+
threadPausedDistribution.track(ms)
11+
}
12+
}

0 commit comments

Comments
 (0)