Skip to content

Commit

Permalink
Ensure plugin do not throw if diagnostics_channel is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart committed Oct 13, 2021
1 parent 52d8351 commit 1953c27
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/datadog-plugin-undici/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ function parseHeaders (headers) {
}

function diagnostics (tracer, config) {
const diagnosticsChannel = require('diagnostics_channel')
let diagnosticsChannel
try {
diagnosticsChannel = require('diagnostics_channel')
} catch (e) {
log.error("Unable to configure undici, cannot require 'diagnostics_channel'")
return () => {}
}
config = normalizeConfig(tracer, config)

const requestChannel = diagnosticsChannel.channel('undici:request:create')
Expand Down

0 comments on commit 1953c27

Please sign in to comment.