Skip to content

Commit 9f5c453

Browse files
committed
Fix comments
1 parent c217880 commit 9f5c453

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface OpenAiIntegration extends Integration {
2525
interface 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)

0 commit comments

Comments
 (0)