Skip to content

Commit 818ad5e

Browse files
committed
Use diag logger instead of throwing errors
1 parent c85ed00 commit 818ad5e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/esbuild-plugin-node/src/common.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ export function wrapModule(
3333
let mod = module.exports;
3434
3535
const { ${oTelInstrumentationClass} } = require('${oTelInstrumentationPackage}');
36+
const { diag } = require('@opentelemetry/api');
3637
const instrumentations = new ${oTelInstrumentationClass}(${oTelInstrumentationConstructorArgs}).getModuleDefinitions();
3738
if (instrumentations.length > 1 && !'${instrumentationName}') {
38-
throw new Error('instrumentationName must be specified because ${oTelInstrumentationClass} has multiple instrumentations');
39+
diag.error('instrumentationName must be specified because ${oTelInstrumentationClass} has multiple instrumentations');
40+
return;
3941
}
4042
const instrumentation = ${
4143
instrumentationName
@@ -44,14 +46,17 @@ export function wrapModule(
4446
};
4547
4648
if (instrumentation.patch && instrumentation.files?.length) {
47-
throw new Error('Not sure how to handle patch and files on instrumentation for ${oTelInstrumentationClass} ${instrumentationName}');
49+
diag.error('Not sure how to handle patch and files on instrumentation for ${oTelInstrumentationClass} ${instrumentationName}');
50+
return;
4851
}
4952
5053
if (!instrumentation.patch) {
5154
if (!instrumentation.files?.length) {
52-
throw new Error('No patch nor files exist on instrumentation for ${oTelInstrumentationClass} ${instrumentationName}');
55+
diag.error('No patch nor files exist on instrumentation for ${oTelInstrumentationClass} ${instrumentationName}');
56+
return;
5357
} else if (instrumentation.files.length > 1) {
54-
throw new Error('Not sure how to handle multiple files for nstrumentations for ${instrumentationName}');
58+
diag.error('Not sure how to handle multiple files for instrumentations for ${instrumentationName}');
59+
return;
5560
}
5661
}
5762

0 commit comments

Comments
 (0)