Skip to content

Commit e99c712

Browse files
committed
Fix wrapper
1 parent 3eaefb7 commit e99c712

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ export function wrapModule(
5252
return;
5353
}
5454
55-
if (!instrumentation.patch) {
55+
if (instrumentation.patch) {
56+
mod = instrumentation.patch(mod)
57+
} else {
5658
if (!instrumentation.files?.length) {
5759
diag.error('No patch nor files exist on instrumentation for ${oTelInstrumentationClass} ${instrumentationName}');
5860
return;
59-
} else if (instrumentation.files.length > 1) {
61+
} else if (instrumentation.files.length === 1) {
62+
mod = instrumentation.files[0].patch(mod);
63+
} else {
6064
const instrumentationFile = instrumentation.files.find(file => file.name === '${instrumentedFileName}');
6165
if (!instrumentationFile) {
6266
diag.error('Not sure how to handle multiple files for instrumentations for ${instrumentationName} when none is found with name ${instrumentedFileName}');
@@ -66,7 +70,6 @@ export function wrapModule(
6670
}
6771
}
6872
69-
mod = instrumentation.patch?.(mod) ?? instrumentation.files[0].patch({ ...mod });
7073
module.exports = mod;
7174
}
7275
`;

0 commit comments

Comments
 (0)