Skip to content

Commit a118cce

Browse files
authored
[DI] Log even more relevant debug info in case of exceptions (#5974)
1 parent c9b3a32 commit a118cce

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

integration-tests/debugger/basic.spec.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,20 +674,25 @@ describe('Dynamic Instrumentation', function () {
674674
})
675675

676676
it('should report error if condition cannot be compiled', function (done) {
677+
const rcConfig = t.generateRemoteConfig({
678+
when: { dsl: 'original dsl', json: { ref: 'this is not a valid ref' } }
679+
})
680+
677681
t.agent.on('debugger-diagnostics', ({ payload }) => {
678682
payload.forEach(({ debugger: { diagnostics } }) => {
679683
if (diagnostics.status === 'ERROR') {
680-
assert.strictEqual(diagnostics.exception.message, 'Cannot compile expression: original dsl')
684+
assert.strictEqual(
685+
diagnostics.exception.message,
686+
`Cannot compile expression: original dsl (probe: ${rcConfig.config.id}, version: 0)`
687+
)
681688
done()
682689
} else if (diagnostics.status === 'INSTALLED') {
683690
assert.fail('Should not install when condition cannot be compiled')
684691
}
685692
})
686693
})
687694

688-
t.agent.addRemoteConfig(t.generateRemoteConfig({
689-
when: { dsl: 'original dsl', json: { ref: 'this is not a valid ref' } }
690-
}))
695+
t.agent.addRemoteConfig(rcConfig)
691696
})
692697
})
693698

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ async function addBreakpoint (probe) {
8787
try {
8888
probe.condition = probe.when?.json && compileCondition(probe.when.json)
8989
} catch (err) {
90-
throw new Error(`Cannot compile expression: ${probe.when.dsl}`, { cause: err })
90+
throw new Error(
91+
`Cannot compile expression: ${probe.when.dsl} (probe: ${probe.id}, version: ${probe.version})`,
92+
{ cause: err }
93+
)
9194
}
9295

9396
const locationKey = generateLocationKey(scriptId, lineNumber, columnNumber)
@@ -115,7 +118,7 @@ async function addBreakpoint (probe) {
115118
condition: probe.condition
116119
})
117120
} catch (err) {
118-
throw new Error(`Error setting breakpoint for probe ${probe.id}`, { cause: err })
121+
throw new Error(`Error setting breakpoint for probe ${probe.id} (version: ${probe.version})`, { cause: err })
119122
}
120123
probeToLocation.set(probe.id, locationKey)
121124
locationToBreakpoint.set(locationKey, { id: result.breakpointId, location, locationKey })
@@ -192,7 +195,7 @@ async function updateBreakpointInternal (breakpoint, probe) {
192195
condition
193196
})
194197
} catch (err) {
195-
throw new Error(`Error setting breakpoint for probe ${probe.id}`, { cause: err })
198+
throw new Error(`Error setting breakpoint for probe ${probe.id} (version: ${probe.version})`, { cause: err })
196199
}
197200
breakpointToProbes.set(result.breakpointId, probesAtLocation)
198201
}

packages/dd-trace/test/debugger/devtools_client/breakpoints.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ describe('breakpoints', function () {
217217
})
218218
.catch((err) => {
219219
expect(err).to.be.instanceOf(Error)
220-
expect(err.message).to.equal('Cannot compile expression: this is an invalid condition')
220+
expect(err.message).to.equal(
221+
'Cannot compile expression: this is an invalid condition (probe: probe-1, version: 1)'
222+
)
221223
})
222224
})
223225
})

0 commit comments

Comments
 (0)