Skip to content

Commit

Permalink
include error type in the telemetry log
Browse files Browse the repository at this point in the history
  • Loading branch information
iunanua committed Nov 13, 2024
1 parent 2023c9e commit 321babd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/dd-trace/src/telemetry/logs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ function onErrorLog (msg) {
level: 'ERROR',

// existing log.error(err) without message will be reported as 'Generic Error'
message: message || 'Generic Error'
message: message ?? 'Generic Error'
}

if (cause) {
telLog.stack_trace = cause.stack
const errorType = cause.name ?? 'Error'
telLog.message = `${errorType}: ${telLog.message}`
}

onLog(telLog)
Expand Down
2 changes: 1 addition & 1 deletion packages/dd-trace/test/telemetry/logs/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('telemetry logs', () => {
errorLog.publish({ cause: error })

expect(logCollectorAdd)
.to.be.calledOnceWith(match({ message: 'Generic Error', level: 'ERROR', stack_trace: stack }))
.to.be.calledOnceWith(match({ message: `${error.name}: Generic Error`, level: 'ERROR', stack_trace: stack }))
})

it('should be called when an error string is published to datadog:log:error', () => {
Expand Down

0 comments on commit 321babd

Please sign in to comment.