Skip to content

Commit

Permalink
[DI] Ensure probe EMITTING status is sent correctly
Browse files Browse the repository at this point in the history
Queue the probe EMITTING status before trying to queue the probe
payload.

Before, the EMITTING status was only emitted if the probe payload was
successfully received by the agnet. If the agent didn't return a HTTP
2xx status code, the EMITTING status would never be sent.
  • Loading branch information
watson committed Jan 19, 2025
1 parent f844865 commit f7cd309
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 2 additions & 3 deletions packages/dd-trace/src/debugger/devtools_client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ session.on('Debugger.paused', async ({ params }) => {
}
}

ackEmitting(probe)
// TODO: Process template (DEBUG-2628)
send(probe.template, logger, dd, snapshot, () => {
ackEmitting(probe)
})
send(probe.template, logger, dd, snapshot)
}
})

Expand Down
8 changes: 1 addition & 7 deletions packages/dd-trace/src/debugger/devtools_client/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ const ddtags = [

const path = `/debugger/v1/input?${stringify({ ddtags })}`

let callbacks = []
const jsonBuffer = new JSONBuffer({ size: config.maxTotalPayloadSize, timeout: 1000, onFlush })

function send (message, logger, dd, snapshot, cb) {
function send (message, logger, dd, snapshot) {
const payload = {
ddsource,
hostname,
Expand All @@ -58,7 +57,6 @@ function send (message, logger, dd, snapshot, cb) {
}

jsonBuffer.write(json, size)
callbacks.push(cb)
}

function onFlush (payload) {
Expand All @@ -69,11 +67,7 @@ function onFlush (payload) {
headers: { 'Content-Type': 'application/json; charset=utf-8' }
}

const _callbacks = callbacks
callbacks = []

request(payload, opts, (err) => {
if (err) log.error('[debugger:devtools_client] Error sending probe payload', err)
else _callbacks.forEach(cb => cb())
})
}

0 comments on commit f7cd309

Please sign in to comment.