File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
packages/node/src/integrations/tracing/openai Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export interface OpenAiIntegration extends Integration {
2525interface PatchedModuleExports {
2626 [ key : string ] : unknown ;
2727 OpenAI : abstract new ( ...args : unknown [ ] ) => OpenAiClient ;
28- AzureOpenAI : abstract new ( ...args : unknown [ ] ) => OpenAiClient ;
28+ AzureOpenAI ? : abstract new ( ...args : unknown [ ] ) => OpenAiClient ;
2929}
3030
3131/**
@@ -57,7 +57,7 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<Instrumenta
5757 }
5858
5959 /**
60- * Core patch logic applying instrumentation to the OpenAI client constructor .
60+ * Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors .
6161 */
6262 private _patch ( exports : PatchedModuleExports ) : PatchedModuleExports | void {
6363 let result = exports ;
@@ -66,8 +66,14 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<Instrumenta
6666 return result ;
6767 }
6868
69+ /**
70+ * Patch logic applying instrumentation to the specified client constructor.
71+ */
6972 private _patchClient ( exports : PatchedModuleExports , exportKey : 'OpenAI' | 'AzureOpenAI' ) : PatchedModuleExports {
7073 const Original = exports [ exportKey ] ;
74+ if ( ! Original ) {
75+ return exports ;
76+ }
7177
7278 const WrappedOpenAI = function ( this : unknown , ...args : unknown [ ] ) {
7379 // Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)
You can’t perform that action at this time.
0 commit comments