Skip to content

Commit 356875c

Browse files
committed
fix(node): Assign default export of openai to the instrumented fn
1 parent 1d59d8a commit 356875c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/node/src/integrations/tracing/openai/instrumentation.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<Instrumenta
9696
enumerable: true,
9797
});
9898
}
99+
100+
// Also wrap the default export if it points to the original constructor
101+
if (exports.default === Original) {
102+
try {
103+
exports.default = WrappedOpenAI;
104+
} catch (error) {
105+
Object.defineProperty(exports, 'default', {
106+
value: WrappedOpenAI,
107+
writable: true,
108+
configurable: true,
109+
enumerable: true,
110+
});
111+
}
112+
}
99113
return exports;
100114
}
101115
}

0 commit comments

Comments
 (0)