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 Jan 31, 2022
1 parent 87bece6 commit 501adc3
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 501adc3

Please sign in to comment.