Skip to content

Commit 25d46fc

Browse files
authored
[DI] Clean up all logs emitted by the debugger (#5008)
1 parent 4304684 commit 25d46fc

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ async function addBreakpoint (probe) {
3636
if (!script) throw new Error(`No loaded script found for ${file} (probe: ${probe.id}, version: ${probe.version})`)
3737
const [path, scriptId] = script
3838

39-
log.debug(`Adding breakpoint at ${path}:${line} (probe: ${probe.id}, version: ${probe.version})`)
39+
log.debug(
40+
'[debugger:devtools_client] Adding breakpoint at %s:%d (probe: %s, version: %d)',
41+
path, line, probe.id, probe.version
42+
)
4043

4144
const { breakpointId } = await session.post('Debugger.setBreakpoint', {
4245
location: {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const config = module.exports = {
1515
updateUrl(parentConfig)
1616

1717
configPort.on('message', updateUrl)
18-
configPort.on('messageerror', (err) => log.error('Debugger config messageerror', err))
18+
configPort.on('messageerror', (err) =>
19+
log.error('[debugger:devtools_client] received "messageerror" on config port', err)
20+
)
1921

2022
function updateUrl (updates) {
2123
config.url = updates.url || format({

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ session.on('Debugger.paused', async ({ params }) => {
7878
await session.post('Debugger.resume')
7979
const diff = process.hrtime.bigint() - start // TODO: Recored as telemetry (DEBUG-2858)
8080

81-
log.debug(`Finished processing breakpoints - main thread paused for: ${Number(diff) / 1000000} ms`)
81+
log.debug(
82+
'[debugger:devtools_client] Finished processing breakpoints - main thread paused for: %d ms',
83+
Number(diff) / 1000000
84+
)
8285

8386
// Due to the highly optimized algorithm above, the `probes` array might have gaps
8487
probes = probes.filter((probe) => !!probe)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ rcPort.on('message', async ({ action, conf: probe, ackId }) => {
4141
ackError(err, probe)
4242
}
4343
})
44-
rcPort.on('messageerror', (err) => log.error('Debugger RC message error', err))
44+
rcPort.on('messageerror', (err) => log.error('[debugger:devtools_client] received "messageerror" on RC port', err))
4545

4646
async function processMsg (action, probe) {
47-
log.debug(`Received request to ${action} ${probe.type} probe (id: ${probe.id}, version: ${probe.version})`)
47+
log.debug(
48+
'[debugger:devtools_client] Received request to %s %s probe (id: %s, version: %d)',
49+
action, probe.type, probe.id, probe.version
50+
)
4851

4952
if (action !== 'unapply') ackReceived(probe)
5053

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function ackEmitting ({ id: probeId, version }) {
5555
}
5656

5757
function ackError (err, { id: probeId, version }) {
58-
log.error('Debugger ackError', err)
58+
log.error('[debugger:devtools_client] ackError', err)
5959

6060
onlyUniqueUpdates(STATUSES.ERROR, probeId, version, () => {
6161
const payload = statusPayload(probeId, version, STATUSES.ERROR)
@@ -87,7 +87,7 @@ function send (payload) {
8787
}
8888

8989
request(form, options, (err) => {
90-
if (err) log.error('Error sending debugger payload', err)
90+
if (err) log.error('[debugger:devtools_client] Error sending debugger payload', err)
9191
})
9292
}
9393

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
function start (config, rc) {
1919
if (worker !== null) return
2020

21-
log.debug('Starting Dynamic Instrumentation client...')
21+
log.debug('[debugger] Starting Dynamic Instrumentation client...')
2222

2323
const rcAckCallbacks = new Map()
2424
const rcChannel = new MessageChannel()
@@ -33,14 +33,14 @@ function start (config, rc) {
3333
const ack = rcAckCallbacks.get(ackId)
3434
if (ack === undefined) {
3535
// This should never happen, but just in case something changes in the future, we should guard against it
36-
log.error('Received an unknown ackId: %s', ackId)
37-
if (error) log.error('Error starting Dynamic Instrumentation client', error)
36+
log.error('[debugger] Received an unknown ackId: %s', ackId)
37+
if (error) log.error('[debugger] Error starting Dynamic Instrumentation client', error)
3838
return
3939
}
4040
ack(error)
4141
rcAckCallbacks.delete(ackId)
4242
})
43-
rcChannel.port2.on('messageerror', (err) => log.error('Debugger RC messageerror', err))
43+
rcChannel.port2.on('messageerror', (err) => log.error('[debugger] received "messageerror" on RC port', err))
4444

4545
worker = new Worker(
4646
join(__dirname, 'devtools_client', 'index.js'),
@@ -58,16 +58,16 @@ function start (config, rc) {
5858
)
5959

6060
worker.on('online', () => {
61-
log.debug(`Dynamic Instrumentation worker thread started successfully (thread id: ${worker.threadId})`)
61+
log.debug('[debugger] Dynamic Instrumentation worker thread started successfully (thread id: %d)', worker.threadId)
6262
})
6363

64-
worker.on('error', (err) => log.error('Debugger worker error', err))
65-
worker.on('messageerror', (err) => log.error('Debugger worker messageerror', err))
64+
worker.on('error', (err) => log.error('[debugger] worker thread error', err))
65+
worker.on('messageerror', (err) => log.error('[debugger] received "messageerror" from worker', err))
6666

6767
worker.on('exit', (code) => {
6868
const error = new Error(`Dynamic Instrumentation worker thread exited unexpectedly with code ${code}`)
6969

70-
log.error('Debugger worker exited unexpectedly', error)
70+
log.error('[debugger] worker thread exited unexpectedly', error)
7171

7272
// Be nice, clean up now that the worker thread encounted an issue and we can't continue
7373
rc.removeProductHandler('LIVE_DEBUGGING')

0 commit comments

Comments
 (0)