Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DI] Ensure probe EMITTING status is sent correctly #5133

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
})
}
20 changes: 3 additions & 17 deletions packages/dd-trace/test/debugger/devtools_client/send.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ describe('input message http requests', function () {
})

it('should call request with the expected payload once the buffer is flushed', function (done) {
const callback1 = sinon.spy()
const callback2 = sinon.spy()
const callback3 = sinon.spy()

send({ message: 1 }, logger, dd, snapshot, callback1)
send({ message: 2 }, logger, dd, snapshot, callback2)
send({ message: 3 }, logger, dd, snapshot, callback3)
send({ message: 1 }, logger, dd, snapshot)
send({ message: 2 }, logger, dd, snapshot)
send({ message: 3 }, logger, dd, snapshot)
expect(request).to.not.have.been.called

expectWithin(1200, () => {
Expand All @@ -83,16 +79,6 @@ describe('input message http requests', function () {
`git.repository_url%3A${repositoryUrl}`
)

expect(callback1).to.not.have.been.calledOnce
expect(callback2).to.not.have.been.calledOnce
expect(callback3).to.not.have.been.calledOnce

request.firstCall.callback()

expect(callback1).to.have.been.calledOnce
expect(callback2).to.have.been.calledOnce
expect(callback3).to.have.been.calledOnce

done()
})
})
Expand Down
Loading