@sentry/node 10.26.0 → 10.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/integrations/tracing/openai/instrumentation.js +17 -4
- package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/openai/instrumentation.js +17 -4
- package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/integrations/tracing/openai/instrumentation.d.ts +5 -1
- package/build/types/integrations/tracing/openai/instrumentation.d.ts.map +1 -1
- package/build/types-ts3.8/integrations/tracing/openai/instrumentation.d.ts +5 -1
- package/package.json +33 -33
|
@@ -34,10 +34,23 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Core patch logic applying instrumentation to the OpenAI client
|
|
37
|
+
* Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.
|
|
38
38
|
*/
|
|
39
39
|
_patch(exports) {
|
|
40
|
-
|
|
40
|
+
let result = exports;
|
|
41
|
+
result = this._patchClient(result, 'OpenAI');
|
|
42
|
+
result = this._patchClient(result, 'AzureOpenAI');
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Patch logic applying instrumentation to the specified client constructor.
|
|
48
|
+
*/
|
|
49
|
+
_patchClient(exports, exportKey) {
|
|
50
|
+
const Original = exports[exportKey];
|
|
51
|
+
if (!Original) {
|
|
52
|
+
return exports;
|
|
53
|
+
}
|
|
41
54
|
|
|
42
55
|
const WrappedOpenAI = function ( ...args) {
|
|
43
56
|
// Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)
|
|
@@ -75,10 +88,10 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
75
88
|
// Constructor replacement - handle read-only properties
|
|
76
89
|
// The OpenAI property might have only a getter, so use defineProperty
|
|
77
90
|
try {
|
|
78
|
-
exports
|
|
91
|
+
exports[exportKey] = WrappedOpenAI;
|
|
79
92
|
} catch (error) {
|
|
80
93
|
// If direct assignment fails, override the property descriptor
|
|
81
|
-
Object.defineProperty(exports,
|
|
94
|
+
Object.defineProperty(exports, exportKey, {
|
|
82
95
|
value: WrappedOpenAI,
|
|
83
96
|
writable: true,
|
|
84
97
|
configurable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport type { Integration, OpenAiClient, OpenAiOptions } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n getClient,\n instrumentOpenAiClient,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=4.0.0 <7'];\n\nexport interface OpenAiIntegration extends Integration {\n options: OpenAiOptions;\n}\n\n/**\n * Represents the patched shape of the OpenAI module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n OpenAI: abstract new (...args: unknown[]) => OpenAiClient;\n}\n\n/**\n * Determines telemetry recording settings.\n */\nfunction determineRecordingSettings(\n integrationOptions: OpenAiOptions | undefined,\n defaultEnabled: boolean,\n): { recordInputs: boolean; recordOutputs: boolean } {\n const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;\n const recordOutputs = integrationOptions?.recordOutputs ?? defaultEnabled;\n return { recordInputs, recordOutputs };\n}\n\n/**\n * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super('@sentry/instrumentation-openai', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition('openai', supportedVersions, this._patch.bind(this));\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the OpenAI client
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport type { Integration, OpenAiClient, OpenAiOptions } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n getClient,\n instrumentOpenAiClient,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=4.0.0 <7'];\n\nexport interface OpenAiIntegration extends Integration {\n options: OpenAiOptions;\n}\n\n/**\n * Represents the patched shape of the OpenAI module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n OpenAI: abstract new (...args: unknown[]) => OpenAiClient;\n AzureOpenAI?: abstract new (...args: unknown[]) => OpenAiClient;\n}\n\n/**\n * Determines telemetry recording settings.\n */\nfunction determineRecordingSettings(\n integrationOptions: OpenAiOptions | undefined,\n defaultEnabled: boolean,\n): { recordInputs: boolean; recordOutputs: boolean } {\n const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;\n const recordOutputs = integrationOptions?.recordOutputs ?? defaultEnabled;\n return { recordInputs, recordOutputs };\n}\n\n/**\n * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super('@sentry/instrumentation-openai', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition('openai', supportedVersions, this._patch.bind(this));\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n let result = exports;\n result = this._patchClient(result, 'OpenAI');\n result = this._patchClient(result, 'AzureOpenAI');\n return result;\n }\n\n /**\n * Patch logic applying instrumentation to the specified client constructor.\n */\n private _patchClient(exports: PatchedModuleExports, exportKey: 'OpenAI' | 'AzureOpenAI'): PatchedModuleExports {\n const Original = exports[exportKey];\n if (!Original) {\n return exports;\n }\n\n const WrappedOpenAI = function (this: unknown, ...args: unknown[]) {\n // Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)\n if (_INTERNAL_shouldSkipAiProviderWrapping(OPENAI_INTEGRATION_NAME)) {\n return Reflect.construct(Original, args) as OpenAiClient;\n }\n\n const instance = Reflect.construct(Original, args);\n const client = getClient();\n const integration = client?.getIntegrationByName<OpenAiIntegration>(OPENAI_INTEGRATION_NAME);\n const integrationOpts = integration?.options;\n const defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOpts, defaultPii);\n\n return instrumentOpenAiClient(instance as OpenAiClient, {\n recordInputs,\n recordOutputs,\n });\n } as unknown as abstract new (...args: unknown[]) => OpenAiClient;\n\n // Preserve static and prototype chains\n Object.setPrototypeOf(WrappedOpenAI, Original);\n Object.setPrototypeOf(WrappedOpenAI.prototype, Original.prototype);\n\n for (const key of Object.getOwnPropertyNames(Original)) {\n if (!['length', 'name', 'prototype'].includes(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(Original, key);\n if (descriptor) {\n Object.defineProperty(WrappedOpenAI, key, descriptor);\n }\n }\n }\n\n // Constructor replacement - handle read-only properties\n // The OpenAI property might have only a getter, so use defineProperty\n try {\n exports[exportKey] = WrappedOpenAI;\n } catch (error) {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportKey, {\n value: WrappedOpenAI,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Wrap the default export if it points to the original constructor\n // Constructor replacement - handle read-only properties\n // The OpenAI property might have only a getter, so use defineProperty\n if (exports.default === Original) {\n try {\n exports.default = WrappedOpenAI;\n } catch (error) {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, 'default', {\n value: WrappedOpenAI,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n return exports;\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","_INTERNAL_shouldSkipAiProviderWrapping","OPENAI_INTEGRATION_NAME","getClient","instrumentOpenAiClient"],"mappings":";;;;;AAeA,MAAM,iBAAA,GAAoB,CAAC,YAAY,CAAC;;AAexC;AACA;AACA;AACA,SAAS,0BAA0B;AACnC,EAAE,kBAAkB;AACpB,EAAE,cAAc;AAChB,EAAqD;AACrD,EAAE,MAAM,YAAA,GAAe,kBAAkB,EAAE,YAAA,IAAgB,cAAc;AACzE,EAAE,MAAM,aAAA,GAAgB,kBAAkB,EAAE,aAAA,IAAiB,cAAc;AAC3E,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe;AACxC;;AAEA;AACA;AACA;AACO,MAAM,2BAAA,SAAoCA,mCAAmB,CAAwB;AAC5F,GAAS,WAAW,CAAC,MAAM,GAA0B,EAAE,EAAE;AACzD,IAAI,KAAK,CAAC,gCAAgC,EAAEC,gBAAW,EAAE,MAAM,CAAC;AAChE,EAAE;;AAEF;AACA;AACA;AACA,GAAS,IAAI,GAAoC;AACjD,IAAI,MAAM,MAAA,GAAS,IAAIC,mDAAmC,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/G,IAAI,OAAO,MAAM;AACjB,EAAE;;AAEF;AACA;AACA;AACA,GAAU,MAAM,CAAC,OAAO,EAAqD;AAC7E,IAAI,IAAI,MAAA,GAAS,OAAO;AACxB,IAAI,MAAA,GAAS,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC;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
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Core patch logic applying instrumentation to the OpenAI client
|
|
35
|
+
* Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.
|
|
36
36
|
*/
|
|
37
37
|
_patch(exports) {
|
|
38
|
-
|
|
38
|
+
let result = exports;
|
|
39
|
+
result = this._patchClient(result, 'OpenAI');
|
|
40
|
+
result = this._patchClient(result, 'AzureOpenAI');
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Patch logic applying instrumentation to the specified client constructor.
|
|
46
|
+
*/
|
|
47
|
+
_patchClient(exports, exportKey) {
|
|
48
|
+
const Original = exports[exportKey];
|
|
49
|
+
if (!Original) {
|
|
50
|
+
return exports;
|
|
51
|
+
}
|
|
39
52
|
|
|
40
53
|
const WrappedOpenAI = function ( ...args) {
|
|
41
54
|
// Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)
|
|
@@ -73,10 +86,10 @@ class SentryOpenAiInstrumentation extends InstrumentationBase {
|
|
|
73
86
|
// Constructor replacement - handle read-only properties
|
|
74
87
|
// The OpenAI property might have only a getter, so use defineProperty
|
|
75
88
|
try {
|
|
76
|
-
exports
|
|
89
|
+
exports[exportKey] = WrappedOpenAI;
|
|
77
90
|
} catch (error) {
|
|
78
91
|
// If direct assignment fails, override the property descriptor
|
|
79
|
-
Object.defineProperty(exports,
|
|
92
|
+
Object.defineProperty(exports, exportKey, {
|
|
80
93
|
value: WrappedOpenAI,
|
|
81
94
|
writable: true,
|
|
82
95
|
configurable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport type { Integration, OpenAiClient, OpenAiOptions } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n getClient,\n instrumentOpenAiClient,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=4.0.0 <7'];\n\nexport interface OpenAiIntegration extends Integration {\n options: OpenAiOptions;\n}\n\n/**\n * Represents the patched shape of the OpenAI module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n OpenAI: abstract new (...args: unknown[]) => OpenAiClient;\n}\n\n/**\n * Determines telemetry recording settings.\n */\nfunction determineRecordingSettings(\n integrationOptions: OpenAiOptions | undefined,\n defaultEnabled: boolean,\n): { recordInputs: boolean; recordOutputs: boolean } {\n const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;\n const recordOutputs = integrationOptions?.recordOutputs ?? defaultEnabled;\n return { recordInputs, recordOutputs };\n}\n\n/**\n * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super('@sentry/instrumentation-openai', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition('openai', supportedVersions, this._patch.bind(this));\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the OpenAI client
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport type { Integration, OpenAiClient, OpenAiOptions } from '@sentry/core';\nimport {\n _INTERNAL_shouldSkipAiProviderWrapping,\n getClient,\n instrumentOpenAiClient,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=4.0.0 <7'];\n\nexport interface OpenAiIntegration extends Integration {\n options: OpenAiOptions;\n}\n\n/**\n * Represents the patched shape of the OpenAI module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n OpenAI: abstract new (...args: unknown[]) => OpenAiClient;\n AzureOpenAI?: abstract new (...args: unknown[]) => OpenAiClient;\n}\n\n/**\n * Determines telemetry recording settings.\n */\nfunction determineRecordingSettings(\n integrationOptions: OpenAiOptions | undefined,\n defaultEnabled: boolean,\n): { recordInputs: boolean; recordOutputs: boolean } {\n const recordInputs = integrationOptions?.recordInputs ?? defaultEnabled;\n const recordOutputs = integrationOptions?.recordOutputs ?? defaultEnabled;\n return { recordInputs, recordOutputs };\n}\n\n/**\n * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super('@sentry/instrumentation-openai', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition('openai', supportedVersions, this._patch.bind(this));\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n let result = exports;\n result = this._patchClient(result, 'OpenAI');\n result = this._patchClient(result, 'AzureOpenAI');\n return result;\n }\n\n /**\n * Patch logic applying instrumentation to the specified client constructor.\n */\n private _patchClient(exports: PatchedModuleExports, exportKey: 'OpenAI' | 'AzureOpenAI'): PatchedModuleExports {\n const Original = exports[exportKey];\n if (!Original) {\n return exports;\n }\n\n const WrappedOpenAI = function (this: unknown, ...args: unknown[]) {\n // Check if wrapping should be skipped (e.g., when LangChain is handling instrumentation)\n if (_INTERNAL_shouldSkipAiProviderWrapping(OPENAI_INTEGRATION_NAME)) {\n return Reflect.construct(Original, args) as OpenAiClient;\n }\n\n const instance = Reflect.construct(Original, args);\n const client = getClient();\n const integration = client?.getIntegrationByName<OpenAiIntegration>(OPENAI_INTEGRATION_NAME);\n const integrationOpts = integration?.options;\n const defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const { recordInputs, recordOutputs } = determineRecordingSettings(integrationOpts, defaultPii);\n\n return instrumentOpenAiClient(instance as OpenAiClient, {\n recordInputs,\n recordOutputs,\n });\n } as unknown as abstract new (...args: unknown[]) => OpenAiClient;\n\n // Preserve static and prototype chains\n Object.setPrototypeOf(WrappedOpenAI, Original);\n Object.setPrototypeOf(WrappedOpenAI.prototype, Original.prototype);\n\n for (const key of Object.getOwnPropertyNames(Original)) {\n if (!['length', 'name', 'prototype'].includes(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(Original, key);\n if (descriptor) {\n Object.defineProperty(WrappedOpenAI, key, descriptor);\n }\n }\n }\n\n // Constructor replacement - handle read-only properties\n // The OpenAI property might have only a getter, so use defineProperty\n try {\n exports[exportKey] = WrappedOpenAI;\n } catch (error) {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, exportKey, {\n value: WrappedOpenAI,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n\n // Wrap the default export if it points to the original constructor\n // Constructor replacement - handle read-only properties\n // The OpenAI property might have only a getter, so use defineProperty\n if (exports.default === Original) {\n try {\n exports.default = WrappedOpenAI;\n } catch (error) {\n // If direct assignment fails, override the property descriptor\n Object.defineProperty(exports, 'default', {\n value: WrappedOpenAI,\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n return exports;\n }\n}\n"],"names":[],"mappings":";;;AAeA,MAAM,iBAAA,GAAoB,CAAC,YAAY,CAAC;;AAexC;AACA;AACA;AACA,SAAS,0BAA0B;AACnC,EAAE,kBAAkB;AACpB,EAAE,cAAc;AAChB,EAAqD;AACrD,EAAE,MAAM,YAAA,GAAe,kBAAkB,EAAE,YAAA,IAAgB,cAAc;AACzE,EAAE,MAAM,aAAA,GAAgB,kBAAkB,EAAE,aAAA,IAAiB,cAAc;AAC3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,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;;AAEJ;AACA;AACA;AACA,IAAI,IAAI,OAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACtC,MAAM,IAAI;AACV,QAAQ,OAAO,CAAC,OAAA,GAAU,aAAa;AACvC,MAAM,CAAA,CAAE,OAAO,KAAK,EAAE;AACtB;AACA,QAAQ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE;AAClD,UAAU,KAAK,EAAE,aAAa;AAC9B,UAAU,QAAQ,EAAE,IAAI;AACxB,UAAU,YAAY,EAAE,IAAI;AAC5B,UAAU,UAAU,EAAE,IAAI;AAC1B,SAAS,CAAC;AACV,MAAM;AACN,IAAI;AACJ,IAAI,OAAO,OAAO;AAClB,EAAE;AACF;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.27.0","sideEffects":false}
|
|
@@ -13,8 +13,12 @@ export declare class SentryOpenAiInstrumentation extends InstrumentationBase<Ins
|
|
|
13
13
|
*/
|
|
14
14
|
init(): InstrumentationModuleDefinition;
|
|
15
15
|
/**
|
|
16
|
-
* Core patch logic applying instrumentation to the OpenAI client
|
|
16
|
+
* Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.
|
|
17
17
|
*/
|
|
18
18
|
private _patch;
|
|
19
|
+
/**
|
|
20
|
+
* Patch logic applying instrumentation to the specified client constructor.
|
|
21
|
+
*/
|
|
22
|
+
private _patchClient;
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,mBAAmB,EAEpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7E,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,OAAO,EAAE,aAAa,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,mBAAmB,EAEpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAgB,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7E,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,OAAO,EAAE,aAAa,CAAC;CACxB;AAuBD;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,mBAAmB,CAAC,qBAAqB,CAAC;gBACtE,MAAM,GAAE,qBAA0B;IAIrD;;OAEG;IACI,IAAI,IAAI,+BAA+B;IAK9C;;OAEG;IACH,OAAO,CAAC,MAAM;IAOd;;OAEG;IACH,OAAO,CAAC,YAAY;CAuErB"}
|
|
@@ -13,8 +13,12 @@ export declare class SentryOpenAiInstrumentation extends InstrumentationBase<Ins
|
|
|
13
13
|
*/
|
|
14
14
|
init(): InstrumentationModuleDefinition;
|
|
15
15
|
/**
|
|
16
|
-
* Core patch logic applying instrumentation to the OpenAI client
|
|
16
|
+
* Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.
|
|
17
17
|
*/
|
|
18
18
|
private _patch;
|
|
19
|
+
/**
|
|
20
|
+
* Patch logic applying instrumentation to the specified client constructor.
|
|
21
|
+
*/
|
|
22
|
+
private _patchClient;
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=instrumentation.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/node",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.27.0",
|
|
4
4
|
"description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
|
|
@@ -66,39 +66,39 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@opentelemetry/api": "^1.9.0",
|
|
69
|
-
"@opentelemetry/context-async-hooks": "^2.
|
|
70
|
-
"@opentelemetry/core": "^2.
|
|
71
|
-
"@opentelemetry/instrumentation": "^0.
|
|
72
|
-
"@opentelemetry/instrumentation-amqplib": "0.
|
|
73
|
-
"@opentelemetry/instrumentation-connect": "0.
|
|
74
|
-
"@opentelemetry/instrumentation-dataloader": "0.
|
|
75
|
-
"@opentelemetry/instrumentation-express": "0.
|
|
76
|
-
"@opentelemetry/instrumentation-fs": "0.
|
|
77
|
-
"@opentelemetry/instrumentation-generic-pool": "0.
|
|
78
|
-
"@opentelemetry/instrumentation-graphql": "0.
|
|
79
|
-
"@opentelemetry/instrumentation-hapi": "0.
|
|
80
|
-
"@opentelemetry/instrumentation-http": "0.
|
|
81
|
-
"@opentelemetry/instrumentation-ioredis": "0.
|
|
82
|
-
"@opentelemetry/instrumentation-kafkajs": "0.
|
|
83
|
-
"@opentelemetry/instrumentation-knex": "0.
|
|
84
|
-
"@opentelemetry/instrumentation-koa": "0.
|
|
85
|
-
"@opentelemetry/instrumentation-lru-memoizer": "0.
|
|
86
|
-
"@opentelemetry/instrumentation-mongodb": "0.
|
|
87
|
-
"@opentelemetry/instrumentation-mongoose": "0.
|
|
88
|
-
"@opentelemetry/instrumentation-mysql": "0.
|
|
89
|
-
"@opentelemetry/instrumentation-mysql2": "0.
|
|
90
|
-
"@opentelemetry/instrumentation-pg": "0.
|
|
91
|
-
"@opentelemetry/instrumentation-redis": "0.
|
|
92
|
-
"@opentelemetry/instrumentation-tedious": "0.
|
|
93
|
-
"@opentelemetry/instrumentation-undici": "0.
|
|
94
|
-
"@opentelemetry/resources": "^2.
|
|
95
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
69
|
+
"@opentelemetry/context-async-hooks": "^2.2.0",
|
|
70
|
+
"@opentelemetry/core": "^2.2.0",
|
|
71
|
+
"@opentelemetry/instrumentation": "^0.208.0",
|
|
72
|
+
"@opentelemetry/instrumentation-amqplib": "0.55.0",
|
|
73
|
+
"@opentelemetry/instrumentation-connect": "0.52.0",
|
|
74
|
+
"@opentelemetry/instrumentation-dataloader": "0.26.0",
|
|
75
|
+
"@opentelemetry/instrumentation-express": "0.57.0",
|
|
76
|
+
"@opentelemetry/instrumentation-fs": "0.28.0",
|
|
77
|
+
"@opentelemetry/instrumentation-generic-pool": "0.52.0",
|
|
78
|
+
"@opentelemetry/instrumentation-graphql": "0.56.0",
|
|
79
|
+
"@opentelemetry/instrumentation-hapi": "0.55.0",
|
|
80
|
+
"@opentelemetry/instrumentation-http": "0.208.0",
|
|
81
|
+
"@opentelemetry/instrumentation-ioredis": "0.56.0",
|
|
82
|
+
"@opentelemetry/instrumentation-kafkajs": "0.18.0",
|
|
83
|
+
"@opentelemetry/instrumentation-knex": "0.53.0",
|
|
84
|
+
"@opentelemetry/instrumentation-koa": "0.57.0",
|
|
85
|
+
"@opentelemetry/instrumentation-lru-memoizer": "0.53.0",
|
|
86
|
+
"@opentelemetry/instrumentation-mongodb": "0.61.0",
|
|
87
|
+
"@opentelemetry/instrumentation-mongoose": "0.55.0",
|
|
88
|
+
"@opentelemetry/instrumentation-mysql": "0.54.0",
|
|
89
|
+
"@opentelemetry/instrumentation-mysql2": "0.55.0",
|
|
90
|
+
"@opentelemetry/instrumentation-pg": "0.61.0",
|
|
91
|
+
"@opentelemetry/instrumentation-redis": "0.57.0",
|
|
92
|
+
"@opentelemetry/instrumentation-tedious": "0.27.0",
|
|
93
|
+
"@opentelemetry/instrumentation-undici": "0.19.0",
|
|
94
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
95
|
+
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
96
96
|
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
97
|
-
"@prisma/instrumentation": "6.
|
|
98
|
-
"@sentry/core": "10.
|
|
99
|
-
"@sentry/node-core": "10.
|
|
100
|
-
"@sentry/opentelemetry": "10.
|
|
101
|
-
"import-in-the-middle": "^
|
|
97
|
+
"@prisma/instrumentation": "6.19.0",
|
|
98
|
+
"@sentry/core": "10.27.0",
|
|
99
|
+
"@sentry/node-core": "10.27.0",
|
|
100
|
+
"@sentry/opentelemetry": "10.27.0",
|
|
101
|
+
"import-in-the-middle": "^2",
|
|
102
102
|
"minimatch": "^9.0.0"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|