@sentry/node 10.37.0 → 10.39.0-alpha.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.
Files changed (50) hide show
  1. package/build/cjs/index.js +29 -24
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/node-fetch.js +1 -1
  4. package/build/cjs/integrations/node-fetch.js.map +1 -1
  5. package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js +8 -8
  6. package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -1
  7. package/build/cjs/integrations/tracing/fastify/index.js +1 -1
  8. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -1
  9. package/build/cjs/integrations/tracing/google-genai/instrumentation.js +9 -9
  10. package/build/cjs/integrations/tracing/google-genai/instrumentation.js.map +1 -1
  11. package/build/cjs/integrations/tracing/langchain/instrumentation.js +9 -9
  12. package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -1
  13. package/build/cjs/integrations/tracing/langgraph/instrumentation.js +6 -6
  14. package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -1
  15. package/build/cjs/integrations/tracing/openai/instrumentation.js +11 -11
  16. package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -1
  17. package/build/cjs/integrations/tracing/postgresjs.js +10 -10
  18. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  19. package/build/cjs/integrations/tracing/vercelai/instrumentation.js +9 -2
  20. package/build/cjs/integrations/tracing/vercelai/instrumentation.js.map +1 -1
  21. package/build/cjs/sdk/initOtel.js +1 -0
  22. package/build/cjs/sdk/initOtel.js.map +1 -1
  23. package/build/esm/index.js +2 -2
  24. package/build/esm/integrations/node-fetch.js +1 -1
  25. package/build/esm/integrations/node-fetch.js.map +1 -1
  26. package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js +8 -8
  27. package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -1
  28. package/build/esm/integrations/tracing/fastify/index.js +1 -1
  29. package/build/esm/integrations/tracing/fastify/index.js.map +1 -1
  30. package/build/esm/integrations/tracing/google-genai/instrumentation.js +9 -9
  31. package/build/esm/integrations/tracing/google-genai/instrumentation.js.map +1 -1
  32. package/build/esm/integrations/tracing/langchain/instrumentation.js +9 -9
  33. package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -1
  34. package/build/esm/integrations/tracing/langgraph/instrumentation.js +6 -6
  35. package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -1
  36. package/build/esm/integrations/tracing/openai/instrumentation.js +11 -11
  37. package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -1
  38. package/build/esm/integrations/tracing/postgresjs.js +10 -10
  39. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  40. package/build/esm/integrations/tracing/vercelai/instrumentation.js +9 -2
  41. package/build/esm/integrations/tracing/vercelai/instrumentation.js.map +1 -1
  42. package/build/esm/package.json +1 -1
  43. package/build/esm/sdk/initOtel.js +1 -0
  44. package/build/esm/sdk/initOtel.js.map +1 -1
  45. package/build/types/index.d.ts +2 -2
  46. package/build/types/index.d.ts.map +1 -1
  47. package/build/types/integrations/tracing/vercelai/instrumentation.d.ts.map +1 -1
  48. package/build/types/sdk/initOtel.d.ts.map +1 -1
  49. package/build/types-ts3.8/index.d.ts +2 -2
  50. package/package.json +5 -5
@@ -21,7 +21,7 @@ class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase
21
21
  '@langchain/langgraph',
22
22
  supportedVersions,
23
23
  this._patch.bind(this),
24
- exports => exports,
24
+ exports$1 => exports$1,
25
25
  [
26
26
  new instrumentation.InstrumentationNodeModuleFile(
27
27
  /**
@@ -33,7 +33,7 @@ class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase
33
33
  '@langchain/langgraph/dist/index.cjs',
34
34
  supportedVersions,
35
35
  this._patch.bind(this),
36
- exports => exports,
36
+ exports$1 => exports$1,
37
37
  ),
38
38
  ],
39
39
  );
@@ -43,7 +43,7 @@ class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase
43
43
  /**
44
44
  * Core patch logic applying instrumentation to the LangGraph module.
45
45
  */
46
- _patch(exports) {
46
+ _patch(exports$1) {
47
47
  const client = core.getClient();
48
48
  const defaultPii = Boolean(client?.getOptions().sendDefaultPii);
49
49
 
@@ -57,8 +57,8 @@ class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase
57
57
  };
58
58
 
59
59
  // Patch StateGraph.compile to instrument both compile() and invoke()
60
- if (exports.StateGraph && typeof exports.StateGraph === 'function') {
61
- const StateGraph = exports.StateGraph
60
+ if (exports$1.StateGraph && typeof exports$1.StateGraph === 'function') {
61
+ const StateGraph = exports$1.StateGraph
62
62
 
63
63
  ;
64
64
 
@@ -68,7 +68,7 @@ class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase
68
68
  );
69
69
  }
70
70
 
71
- return exports;
71
+ return exports$1;
72
72
  }
73
73
  }
74
74
 
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langgraph/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { CompiledGraph, LangGraphOptions } from '@sentry/core';\nimport { getClient, instrumentStateGraphCompile, SDK_VERSION } from '@sentry/core';\n\nconst supportedVersions = ['>=0.0.0 <2.0.0'];\n\ntype LangGraphInstrumentationOptions = InstrumentationConfig & LangGraphOptions;\n\n/**\n * Represents the patched shape of the LangGraph module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n StateGraph?: abstract new (...args: unknown[]) => unknown;\n}\n\n/**\n * Sentry LangGraph instrumentation using OpenTelemetry.\n */\nexport class SentryLangGraphInstrumentation extends InstrumentationBase<LangGraphInstrumentationOptions> {\n public constructor(config: LangGraphInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langgraph', 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(\n '@langchain/langgraph',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n /**\n * In CJS, LangGraph packages re-export from dist/index.cjs files.\n * Patching only the root module sometimes misses the real implementation or\n * gets overwritten when that file is loaded. We add a file-level patch so that\n * _patch runs again on the concrete implementation\n */\n '@langchain/langgraph/dist/index.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n );\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the LangGraph module.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n const client = getClient();\n const defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const config = this.getConfig();\n const recordInputs = config.recordInputs ?? defaultPii;\n const recordOutputs = config.recordOutputs ?? defaultPii;\n\n const options: LangGraphOptions = {\n recordInputs,\n recordOutputs,\n };\n\n // Patch StateGraph.compile to instrument both compile() and invoke()\n if (exports.StateGraph && typeof exports.StateGraph === 'function') {\n const StateGraph = exports.StateGraph as {\n prototype: Record<string, unknown>;\n };\n\n StateGraph.prototype.compile = instrumentStateGraphCompile(\n StateGraph.prototype.compile as (...args: unknown[]) => CompiledGraph,\n options,\n );\n }\n\n return exports;\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","getClient","instrumentStateGraphCompile"],"mappings":";;;;;AAUA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAY5C;AACA;AACA;AACO,MAAM,8BAAA,SAAuCA,mCAAmB,CAAkC;AACzG,GAAS,WAAW,CAAC,MAAM,GAAoC,EAAE,EAAE;AACnE,IAAI,KAAK,CAAC,mCAAmC,EAAEC,gBAAW,EAAE,MAAM,CAAC;AACnE,EAAE;;AAEF;AACA;AACA;AACA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ClB,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langgraph/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { CompiledGraph, LangGraphOptions } from '@sentry/core';\nimport { getClient, instrumentStateGraphCompile, SDK_VERSION } from '@sentry/core';\n\nconst supportedVersions = ['>=0.0.0 <2.0.0'];\n\ntype LangGraphInstrumentationOptions = InstrumentationConfig & LangGraphOptions;\n\n/**\n * Represents the patched shape of the LangGraph module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n StateGraph?: abstract new (...args: unknown[]) => unknown;\n}\n\n/**\n * Sentry LangGraph instrumentation using OpenTelemetry.\n */\nexport class SentryLangGraphInstrumentation extends InstrumentationBase<LangGraphInstrumentationOptions> {\n public constructor(config: LangGraphInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langgraph', 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(\n '@langchain/langgraph',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n /**\n * In CJS, LangGraph packages re-export from dist/index.cjs files.\n * Patching only the root module sometimes misses the real implementation or\n * gets overwritten when that file is loaded. We add a file-level patch so that\n * _patch runs again on the concrete implementation\n */\n '@langchain/langgraph/dist/index.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n );\n return module;\n }\n\n /**\n * Core patch logic applying instrumentation to the LangGraph module.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n const client = getClient();\n const defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const config = this.getConfig();\n const recordInputs = config.recordInputs ?? defaultPii;\n const recordOutputs = config.recordOutputs ?? defaultPii;\n\n const options: LangGraphOptions = {\n recordInputs,\n recordOutputs,\n };\n\n // Patch StateGraph.compile to instrument both compile() and invoke()\n if (exports.StateGraph && typeof exports.StateGraph === 'function') {\n const StateGraph = exports.StateGraph as {\n prototype: Record<string, unknown>;\n };\n\n StateGraph.prototype.compile = instrumentStateGraphCompile(\n StateGraph.prototype.compile as (...args: unknown[]) => CompiledGraph,\n options,\n );\n }\n\n return exports;\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","exports","InstrumentationNodeModuleFile","getClient","instrumentStateGraphCompile"],"mappings":";;;;;AAUA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAY5C;AACA;AACA;AACO,MAAM,8BAAA,SAAuCA,mCAAmB,CAAkC;AACzG,GAAS,WAAW,CAAC,MAAM,GAAoC,EAAE,EAAE;AACnE,IAAI,KAAK,CAAC,mCAAmC,EAAEC,gBAAW,EAAE,MAAM,CAAC;AACnE,EAAE;;AAEF;AACA;AACA;AACA,GAAS,IAAI,GAAoC;AACjD,IAAI,MAAM,MAAA,GAAS,IAAIC,mDAAmC;AAC1D,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB;AACvB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5B,MAAMC,SAAA,IAAWA,SAAO;AACxB,MAAM;AACN,QAAQ,IAAIC,6CAA6B;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,qCAAqC;AAC/C,UAAU,iBAAiB;AAC3B,UAAU,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;AAChC,UAAUD,SAAA,IAAWA,SAAO;AAC5B,SAAS;AACT,OAAO;AACP,KAAK;AACL,IAAI,OAAO,MAAM;AACjB,EAAE;;AAEF;AACA;AACA;AACA,GAAU,MAAM,CAACA,SAAO,EAAqD;AAC7E,IAAI,MAAM,MAAA,GAASE,cAAS,EAAE;AAC9B,IAAI,MAAM,UAAA,GAAa,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,cAAc,CAAC;;AAEnE,IAAI,MAAM,MAAA,GAAS,IAAI,CAAC,SAAS,EAAE;AACnC,IAAI,MAAM,YAAA,GAAe,MAAM,CAAC,YAAA,IAAgB,UAAU;AAC1D,IAAI,MAAM,aAAA,GAAgB,MAAM,CAAC,aAAA,IAAiB,UAAU;;AAE5D,IAAI,MAAM,OAAO,GAAqB;AACtC,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,KAAK;;AAEL;AACA,IAAI,IAAIF,SAAO,CAAC,UAAA,IAAc,OAAOA,SAAO,CAAC,UAAA,KAAe,UAAU,EAAE;AACxE,MAAM,MAAM,UAAA,GAAaA,SAAO,CAAC;;AAE3B;;AAEN,MAAM,UAAU,CAAC,SAAS,CAAC,OAAA,GAAUG,gCAA2B;AAChE,QAAQ,UAAU,CAAC,SAAS,CAAC,OAAA;AAC7B,QAAQ,OAAO;AACf,OAAO;AACP,IAAI;;AAEJ,IAAI,OAAOH,SAAO;AAClB,EAAE;AACF;;;;"}
@@ -24,8 +24,8 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
24
24
  /**
25
25
  * Core patch logic applying instrumentation to the OpenAI and AzureOpenAI client constructors.
26
26
  */
27
- _patch(exports) {
28
- let result = exports;
27
+ _patch(exports$1) {
28
+ let result = exports$1;
29
29
  result = this._patchClient(result, 'OpenAI');
30
30
  result = this._patchClient(result, 'AzureOpenAI');
31
31
  return result;
@@ -34,10 +34,10 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
34
34
  /**
35
35
  * Patch logic applying instrumentation to the specified client constructor.
36
36
  */
37
- _patchClient(exports, exportKey) {
38
- const Original = exports[exportKey];
37
+ _patchClient(exports$1, exportKey) {
38
+ const Original = exports$1[exportKey];
39
39
  if (!Original) {
40
- return exports;
40
+ return exports$1;
41
41
  }
42
42
 
43
43
  const config = this.getConfig();
@@ -77,10 +77,10 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
77
77
  // Constructor replacement - handle read-only properties
78
78
  // The OpenAI property might have only a getter, so use defineProperty
79
79
  try {
80
- exports[exportKey] = WrappedOpenAI;
80
+ exports$1[exportKey] = WrappedOpenAI;
81
81
  } catch (error) {
82
82
  // If direct assignment fails, override the property descriptor
83
- Object.defineProperty(exports, exportKey, {
83
+ Object.defineProperty(exports$1, exportKey, {
84
84
  value: WrappedOpenAI,
85
85
  writable: true,
86
86
  configurable: true,
@@ -91,12 +91,12 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
91
91
  // Wrap the default export if it points to the original constructor
92
92
  // Constructor replacement - handle read-only properties
93
93
  // The OpenAI property might have only a getter, so use defineProperty
94
- if (exports.default === Original) {
94
+ if (exports$1.default === Original) {
95
95
  try {
96
- exports.default = WrappedOpenAI;
96
+ exports$1.default = WrappedOpenAI;
97
97
  } catch (error) {
98
98
  // If direct assignment fails, override the property descriptor
99
- Object.defineProperty(exports, 'default', {
99
+ Object.defineProperty(exports$1, 'default', {
100
100
  value: WrappedOpenAI,
101
101
  writable: true,
102
102
  configurable: true,
@@ -104,7 +104,7 @@ class SentryOpenAiInstrumentation extends instrumentation.InstrumentationBase {
104
104
  });
105
105
  }
106
106
  }
107
- return exports;
107
+ return exports$1;
108
108
  }
109
109
  }
110
110
 
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\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\ntype OpenAiInstrumentationOptions = InstrumentationConfig & OpenAiOptions;\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 * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<OpenAiInstrumentationOptions> {\n public constructor(config: OpenAiInstrumentationOptions = {}) {\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 config = this.getConfig();\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 defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const recordInputs = config.recordInputs ?? defaultPii;\n const recordOutputs = config.recordOutputs ?? 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;;AAiBxC;AACA;AACA;AACO,MAAM,2BAAA,SAAoCA,mCAAmB,CAA+B;AACnG,GAAS,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AAChE,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,C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B,UAAU,YAAY,EAAE,IAAI;AAC5B,UAAU,UAAU,EAAE,IAAI;AAC1B,SAAS,CAAC;AACV,MAAM;AACN,IAAI;AACJ,IAAI,OAAO,OAAO;AAClB,EAAE;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/openai/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\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\ntype OpenAiInstrumentationOptions = InstrumentationConfig & OpenAiOptions;\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 * Sentry OpenAI instrumentation using OpenTelemetry.\n */\nexport class SentryOpenAiInstrumentation extends InstrumentationBase<OpenAiInstrumentationOptions> {\n public constructor(config: OpenAiInstrumentationOptions = {}) {\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 config = this.getConfig();\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 defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const recordInputs = config.recordInputs ?? defaultPii;\n const recordOutputs = config.recordOutputs ?? 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","exports","_INTERNAL_shouldSkipAiProviderWrapping","OPENAI_INTEGRATION_NAME","getClient","instrumentOpenAiClient"],"mappings":";;;;;AAeA,MAAM,iBAAA,GAAoB,CAAC,YAAY,CAAC;;AAiBxC;AACA;AACA;AACO,MAAM,2BAAA,SAAoCA,mCAAmB,CAA+B;AACnG,GAAS,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AAChE,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,CAACC,SAAO,EAAqD;AAC7E,IAAI,IAAI,MAAA,GAASA,SAAO;AACxB,IAAI,MAAA,GAAS,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC;AAChD,IAAI,MAAA,GAAS,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,CAAC;AACrD,IAAI,OAAO,MAAM;AACjB,EAAE;;AAEF;AACA;AACA;AACA,GAAU,YAAY,CAACA,SAAO,EAAwB,SAAS,EAAkD;AACjH,IAAI,MAAM,QAAA,GAAWA,SAAO,CAAC,SAAS,CAAC;AACvC,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,MAAM,OAAOA,SAAO;AACpB,IAAI;;AAEJ,IAAI,MAAM,MAAA,GAAS,IAAI,CAAC,SAAS,EAAE;;AAEnC,IAAI,MAAM,gBAAgB,WAAyB,GAAG,IAAI,EAAa;AACvE;AACA,MAAM,IAAIC,2CAAsC,CAACC,4BAAuB,CAAC,E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E;AACpB;AACA,MAAM,MAAM,CAAC,cAAc,CAACA,SAAO,EAAE,SAAS,EAAE;AAChD,QAAQ,KAAK,EAAE,aAAa;AAC5B,QAAQ,QAAQ,EAAE,IAAI;AACtB,QAAQ,YAAY,EAAE,IAAI;AAC1B,QAAQ,UAAU,EAAE,IAAI;AACxB,OAAO,CAAC;AACR,IAAI;;AAEJ;AACA;AACA;AACA,IAAI,IAAIA,SAAO,CAAC,OAAA,KAAY,QAAQ,EAAE;AACtC,MAAM,IAAI;AACV,QAAQA,SAAO,CAAC,OAAA,GAAU,aAAa;AACvC,MAAM,CAAA,CAAE,OAAO,KAAK,EAAE;AACtB;AACA,QAAQ,MAAM,CAAC,cAAc,CAACA,SAAO,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,OAAOA,SAAO;AAClB,EAAE;AACF;;;;"}
@@ -51,15 +51,15 @@ class PostgresJsInstrumentation extends instrumentation.InstrumentationBase {
51
51
  const module = new instrumentation.InstrumentationNodeModuleDefinition(
52
52
  'postgres',
53
53
  SUPPORTED_VERSIONS,
54
- exports => {
54
+ exports$1 => {
55
55
  try {
56
- return this._patchPostgres(exports);
56
+ return this._patchPostgres(exports$1);
57
57
  } catch (e) {
58
58
  debugBuild.DEBUG_BUILD && core.debug.error('Failed to patch postgres module:', e);
59
- return exports;
59
+ return exports$1;
60
60
  }
61
61
  },
62
- exports => exports,
62
+ exports$1 => exports$1,
63
63
  );
64
64
 
65
65
  // Add fallback Query.prototype patching for pre-existing sql instances (CJS only)
@@ -82,15 +82,15 @@ class PostgresJsInstrumentation extends instrumentation.InstrumentationBase {
82
82
  * Patches the postgres module by wrapping the main export function.
83
83
  * This intercepts the creation of sql instances and instruments them.
84
84
  */
85
- _patchPostgres(exports) {
85
+ _patchPostgres(exports$1) {
86
86
  // In CJS: exports is the function itself
87
87
  // In ESM: exports.default is the function
88
- const isFunction = typeof exports === 'function';
89
- const Original = isFunction ? exports : exports.default;
88
+ const isFunction = typeof exports$1 === 'function';
89
+ const Original = isFunction ? exports$1 : exports$1.default;
90
90
 
91
91
  if (typeof Original !== 'function') {
92
92
  debugBuild.DEBUG_BUILD && core.debug.warn('postgres module does not export a function. Skipping instrumentation.');
93
- return exports;
93
+ return exports$1;
94
94
  }
95
95
 
96
96
  // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -125,8 +125,8 @@ class PostgresJsInstrumentation extends instrumentation.InstrumentationBase {
125
125
  if (isFunction) {
126
126
  return WrappedPostgres ;
127
127
  } else {
128
- core.replaceExports(exports, 'default', WrappedPostgres);
129
- return exports;
128
+ core.replaceExports(exports$1, 'default', WrappedPostgres);
129
+ return exports$1;
130
130
  }
131
131
  }
132
132
 
@@ -1 +1 @@
1
- {"version":3,"file":"postgresjs.js","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"sourcesContent":["/* eslint-disable max-lines */\n// Instrumentation for https://github.com/porsager/postgres\n\nimport { context, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_RESPONSE_STATUS_CODE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n replaceExports,\n SDK_VERSION,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../../debug-build';\n\nconst INTEGRATION_NAME = 'PostgresJs';\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <4'];\nconst SQL_OPERATION_REGEX = /^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i;\n\ntype PostgresConnectionContext = {\n ATTR_DB_NAMESPACE?: string; // Database name\n ATTR_SERVER_ADDRESS?: string; // Hostname or IP address of the database server\n ATTR_SERVER_PORT?: string; // Port number of the database server\n};\n\nconst CONNECTION_CONTEXT_SYMBOL = Symbol('sentryPostgresConnectionContext');\nconst INSTRUMENTED_MARKER = Symbol.for('sentry.instrumented.postgresjs');\n// Marker to track if a query was created from an instrumented sql instance\n// This prevents double-spanning when both wrapper and prototype patches are active\nconst QUERY_FROM_INSTRUMENTED_SQL = Symbol.for('sentry.query.from.instrumented.sql');\n\ntype PostgresJsInstrumentationConfig = InstrumentationConfig & {\n /**\n * Whether to require a parent span for the instrumentation.\n * If set to true, the instrumentation will only create spans if there is a parent span\n * available in the current scope.\n * @default true\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the span before it is started.\n * This can be used to set additional attributes or modify the span in any way.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n};\n\nexport const instrumentPostgresJs = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: PostgresJsInstrumentationConfig) =>\n new PostgresJsInstrumentation({\n requireParentSpan: options?.requireParentSpan ?? true,\n requestHook: options?.requestHook,\n }),\n);\n\n/**\n * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n * This instrumentation captures postgresjs queries and their attributes.\n *\n * Uses internal Sentry patching patterns to support both CommonJS and ESM environments.\n */\nexport class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {\n public constructor(config: PostgresJsInstrumentationConfig) {\n super('sentry-postgres-js', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by patching the postgres module.\n * Uses two complementary approaches:\n * 1. Main function wrapper: instruments sql instances created AFTER instrumentation is set up (CJS + ESM)\n * 2. Query.prototype patch: fallback for sql instances created BEFORE instrumentation (CJS only)\n */\n public init(): InstrumentationNodeModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'postgres',\n SUPPORTED_VERSIONS,\n exports => {\n try {\n return this._patchPostgres(exports);\n } catch (e) {\n DEBUG_BUILD && debug.error('Failed to patch postgres module:', e);\n return exports;\n }\n },\n exports => exports,\n );\n\n // Add fallback Query.prototype patching for pre-existing sql instances (CJS only)\n // This catches queries from sql instances created before Sentry was initialized\n ['src', 'cf/src', 'cjs/src'].forEach(path => {\n module.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/query.js`,\n SUPPORTED_VERSIONS,\n this._patchQueryPrototype.bind(this),\n this._unpatchQueryPrototype.bind(this),\n ),\n );\n });\n\n return module;\n }\n\n /**\n * Patches the postgres module by wrapping the main export function.\n * This intercepts the creation of sql instances and instruments them.\n */\n private _patchPostgres(exports: { [key: string]: unknown }): { [key: string]: unknown } {\n // In CJS: exports is the function itself\n // In ESM: exports.default is the function\n const isFunction = typeof exports === 'function';\n const Original = isFunction ? exports : exports.default;\n\n if (typeof Original !== 'function') {\n DEBUG_BUILD && debug.warn('postgres module does not export a function. Skipping instrumentation.');\n return exports;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n const WrappedPostgres = function (this: unknown, ...args: unknown[]): unknown {\n const sql = Reflect.construct(Original as (...args: unknown[]) => unknown, args);\n\n // Validate that construction succeeded and returned a valid function object\n if (!sql || typeof sql !== 'function') {\n DEBUG_BUILD && debug.warn('postgres() did not return a valid instance');\n return sql;\n }\n\n return self._instrumentSqlInstance(sql);\n };\n\n Object.setPrototypeOf(WrappedPostgres, Original);\n Object.setPrototypeOf(WrappedPostgres.prototype, (Original as { prototype: object }).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(WrappedPostgres, key, descriptor);\n }\n }\n }\n\n // For CJS: the exports object IS the function, so return the wrapped function\n // For ESM: replace the default export\n if (isFunction) {\n return WrappedPostgres as unknown as { [key: string]: unknown };\n } else {\n replaceExports(exports, 'default', WrappedPostgres);\n return exports;\n }\n }\n\n /**\n * Wraps query-returning methods (unsafe, file) to ensure their queries are instrumented.\n */\n private _wrapQueryMethod(\n original: (...args: unknown[]) => unknown,\n target: unknown,\n proxiedSql: unknown,\n ): (...args: unknown[]) => unknown {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n return function (this: unknown, ...args: unknown[]): unknown {\n const query = Reflect.apply(original, target, args);\n\n if (query && typeof query === 'object' && 'handle' in query) {\n self._wrapSingleQueryHandle(query as { handle: unknown; strings?: string[] }, proxiedSql);\n }\n\n return query;\n };\n }\n\n /**\n * Wraps callback-based methods (begin, reserve) to recursively instrument Sql instances.\n * Note: These methods can also be used as tagged templates, which we pass through unchanged.\n *\n * Savepoint is not wrapped to avoid complex nested transaction instrumentation issues.\n * Queries within savepoint callbacks are still instrumented through the parent transaction's Sql instance.\n */\n private _wrapCallbackMethod(\n original: (...args: unknown[]) => unknown,\n target: unknown,\n parentSqlInstance: unknown,\n ): (...args: unknown[]) => unknown {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n return function (this: unknown, ...args: unknown[]): unknown {\n // Extract parent context to propagate to child instances\n const parentContext = (parentSqlInstance as Record<symbol, unknown>)[CONNECTION_CONTEXT_SYMBOL] as\n | PostgresConnectionContext\n | undefined;\n\n // Check if this is a callback-based call by verifying the last argument is a function\n const isCallbackBased = typeof args[args.length - 1] === 'function';\n\n if (!isCallbackBased) {\n // Not a callback-based call - could be tagged template or promise-based\n const result = Reflect.apply(original, target, args);\n // If result is a Promise (e.g., reserve() without callback), instrument the resolved Sql instance\n if (result && typeof (result as Promise<unknown>).then === 'function') {\n return (result as Promise<unknown>).then((sqlInstance: unknown) => {\n return self._instrumentSqlInstance(sqlInstance, parentContext);\n });\n }\n return result;\n }\n\n // Callback-based call: wrap the callback to instrument the Sql instance\n const callback = (args.length === 1 ? args[0] : args[1]) as (sql: unknown) => unknown;\n const wrappedCallback = function (sqlInstance: unknown): unknown {\n const instrumentedSql = self._instrumentSqlInstance(sqlInstance, parentContext);\n return callback(instrumentedSql);\n };\n\n const newArgs = args.length === 1 ? [wrappedCallback] : [args[0], wrappedCallback];\n return Reflect.apply(original, target, newArgs);\n };\n }\n\n /**\n * Sets connection context attributes on a span.\n */\n private _setConnectionAttributes(span: Span, connectionContext: PostgresConnectionContext | undefined): void {\n if (!connectionContext) {\n return;\n }\n if (connectionContext.ATTR_DB_NAMESPACE) {\n span.setAttribute(ATTR_DB_NAMESPACE, connectionContext.ATTR_DB_NAMESPACE);\n }\n if (connectionContext.ATTR_SERVER_ADDRESS) {\n span.setAttribute(ATTR_SERVER_ADDRESS, connectionContext.ATTR_SERVER_ADDRESS);\n }\n if (connectionContext.ATTR_SERVER_PORT !== undefined) {\n // Port is stored as string in PostgresConnectionContext for requestHook backwards compatibility,\n // but OTEL semantic conventions expect port as a number for span attributes\n const portNumber = parseInt(connectionContext.ATTR_SERVER_PORT, 10);\n if (!isNaN(portNumber)) {\n span.setAttribute(ATTR_SERVER_PORT, portNumber);\n }\n }\n }\n\n /**\n * Extracts DB operation name from SQL query and sets it on the span.\n */\n private _setOperationName(span: Span, sanitizedQuery: string | undefined, command?: string): void {\n if (command) {\n span.setAttribute(ATTR_DB_OPERATION_NAME, command);\n return;\n }\n // Fallback: extract operation from the SQL query\n const operationMatch = sanitizedQuery?.match(SQL_OPERATION_REGEX);\n if (operationMatch?.[1]) {\n span.setAttribute(ATTR_DB_OPERATION_NAME, operationMatch[1].toUpperCase());\n }\n }\n\n /**\n * Extracts and stores connection context from sql.options.\n */\n private _attachConnectionContext(sql: unknown, proxiedSql: Record<symbol, unknown>): void {\n const sqlInstance = sql as { options?: { host?: string[]; port?: number[]; database?: string } };\n if (!sqlInstance.options || typeof sqlInstance.options !== 'object') {\n return;\n }\n\n const opts = sqlInstance.options;\n // postgres.js stores parsed options with host and port as arrays\n // The library defaults to 'localhost' and 5432 if not specified, but we're defensive here\n const host = opts.host?.[0] || 'localhost';\n const port = opts.port?.[0] || 5432;\n\n const connectionContext: PostgresConnectionContext = {\n ATTR_DB_NAMESPACE: typeof opts.database === 'string' && opts.database !== '' ? opts.database : undefined,\n ATTR_SERVER_ADDRESS: host,\n ATTR_SERVER_PORT: String(port),\n };\n\n proxiedSql[CONNECTION_CONTEXT_SYMBOL] = connectionContext;\n }\n\n /**\n * Instruments a sql instance by wrapping its query execution methods.\n */\n private _instrumentSqlInstance(sql: unknown, parentConnectionContext?: PostgresConnectionContext): unknown {\n // Check if already instrumented to prevent double-wrapping\n // Using Symbol.for() ensures the marker survives proxying\n if ((sql as Record<symbol, unknown>)[INSTRUMENTED_MARKER]) {\n return sql;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n // Wrap the sql function to intercept query creation\n const proxiedSql: unknown = new Proxy(sql as (...args: unknown[]) => unknown, {\n apply(target, thisArg, argumentsList: unknown[]) {\n const query = Reflect.apply(target, thisArg, argumentsList);\n\n if (query && typeof query === 'object' && 'handle' in query) {\n self._wrapSingleQueryHandle(query as { handle: unknown; strings?: string[] }, proxiedSql);\n }\n\n return query;\n },\n get(target, prop) {\n const original = (target as unknown as Record<string | symbol, unknown>)[prop];\n\n if (typeof prop !== 'string' || typeof original !== 'function') {\n return original;\n }\n\n // Wrap methods that return PendingQuery objects (unsafe, file)\n if (prop === 'unsafe' || prop === 'file') {\n return self._wrapQueryMethod(original as (...args: unknown[]) => unknown, target, proxiedSql);\n }\n\n // Wrap begin and reserve (not savepoint to avoid duplicate spans)\n if (prop === 'begin' || prop === 'reserve') {\n return self._wrapCallbackMethod(original as (...args: unknown[]) => unknown, target, proxiedSql);\n }\n\n return original;\n },\n });\n\n // Use provided parent context if available, otherwise extract from sql.options\n if (parentConnectionContext) {\n (proxiedSql as Record<symbol, unknown>)[CONNECTION_CONTEXT_SYMBOL] = parentConnectionContext;\n } else {\n this._attachConnectionContext(sql, proxiedSql as Record<symbol, unknown>);\n }\n\n // Mark both the original and proxy as instrumented to prevent double-wrapping\n // The proxy might be passed to other methods, or the original\n // might be accessed directly, so we need to mark both\n (sql as Record<symbol, unknown>)[INSTRUMENTED_MARKER] = true;\n (proxiedSql as Record<symbol, unknown>)[INSTRUMENTED_MARKER] = true;\n\n return proxiedSql;\n }\n\n /**\n * Wraps a single query's handle method to create spans.\n */\n private _wrapSingleQueryHandle(\n query: { handle: unknown; strings?: string[]; __sentryWrapped?: boolean },\n sqlInstance: unknown,\n ): void {\n // Prevent double wrapping - check if the handle itself is already wrapped\n if ((query.handle as { __sentryWrapped?: boolean })?.__sentryWrapped) {\n return;\n }\n\n // Mark this query as coming from an instrumented sql instance\n // This prevents the Query.prototype fallback patch from double-spanning\n (query as Record<symbol, unknown>)[QUERY_FROM_INSTRUMENTED_SQL] = true;\n\n const originalHandle = query.handle as (...args: unknown[]) => Promise<unknown>;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n // IMPORTANT: We must replace the handle function directly, not use a Proxy,\n // because Query.then() internally calls this.handle(), which would bypass a Proxy wrapper.\n const wrappedHandle = async function (this: unknown, ...args: unknown[]): Promise<unknown> {\n if (!self._shouldCreateSpans()) {\n return originalHandle.apply(this, args);\n }\n\n const fullQuery = self._reconstructQuery(query.strings);\n const sanitizedSqlQuery = self._sanitizeSqlQuery(fullQuery);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n addOriginToSpan(span, 'auto.db.postgresjs');\n\n span.setAttributes({\n [ATTR_DB_SYSTEM_NAME]: 'postgres',\n [ATTR_DB_QUERY_TEXT]: sanitizedSqlQuery,\n });\n\n const connectionContext = sqlInstance\n ? ((sqlInstance as Record<symbol, unknown>)[CONNECTION_CONTEXT_SYMBOL] as\n | PostgresConnectionContext\n | undefined)\n : undefined;\n\n self._setConnectionAttributes(span, connectionContext);\n\n const config = self.getConfig();\n const { requestHook } = config;\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, connectionContext),\n e => {\n if (e) {\n span.setAttribute('sentry.hook.error', 'requestHook failed');\n DEBUG_BUILD && debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, e);\n }\n },\n true,\n );\n }\n\n const queryWithCallbacks = this as {\n resolve: unknown;\n reject: unknown;\n };\n\n queryWithCallbacks.resolve = new Proxy(queryWithCallbacks.resolve as (...args: unknown[]) => unknown, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n try {\n self._setOperationName(span, sanitizedSqlQuery, resolveArgs?.[0]?.command);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in resolve callback:', e);\n }\n\n return Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n },\n });\n\n queryWithCallbacks.reject = new Proxy(queryWithCallbacks.reject as (...args: unknown[]) => unknown, {\n apply: (rejectTarget, rejectThisArg, rejectArgs: { message?: string; code?: string; name?: string }[]) => {\n try {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'unknown');\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'unknown');\n\n self._setOperationName(span, sanitizedSqlQuery);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in reject callback:', e);\n }\n return Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n },\n });\n\n // Handle synchronous errors that might occur before promise is created\n try {\n return originalHandle.apply(this, args);\n } catch (e) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: e instanceof Error ? e.message : 'unknown_error',\n });\n span.end();\n throw e;\n }\n },\n );\n };\n\n (wrappedHandle as { __sentryWrapped?: boolean }).__sentryWrapped = true;\n query.handle = wrappedHandle;\n }\n\n /**\n * Determines whether a span should be created based on the current context.\n * If `requireParentSpan` is set to true in the configuration, a span will\n * only be created if there is a parent span available.\n */\n private _shouldCreateSpans(): boolean {\n const config = this.getConfig();\n const hasParentSpan = trace.getSpan(context.active()) !== undefined;\n return hasParentSpan || !config.requireParentSpan;\n }\n\n /**\n * Reconstructs the full SQL query from template strings with PostgreSQL placeholders.\n *\n * For sql`SELECT * FROM users WHERE id = ${123} AND name = ${'foo'}`:\n * strings = [\"SELECT * FROM users WHERE id = \", \" AND name = \", \"\"]\n * returns: \"SELECT * FROM users WHERE id = $1 AND name = $2\"\n */\n private _reconstructQuery(strings: string[] | undefined): string | undefined {\n if (!strings?.length) {\n return undefined;\n }\n if (strings.length === 1) {\n return strings[0] || undefined;\n }\n // Join template parts with PostgreSQL placeholders ($1, $2, etc.)\n return strings.reduce((acc, str, i) => (i === 0 ? str : `${acc}$${i}${str}`), '');\n }\n\n /**\n * Sanitize SQL query as per the OTEL semantic conventions\n * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext\n *\n * PostgreSQL $n placeholders are preserved per OTEL spec - they're parameterized queries,\n * not sensitive literals. Only actual values (strings, numbers, booleans) are sanitized.\n */\n private _sanitizeSqlQuery(sqlQuery: string | undefined): string {\n if (!sqlQuery) {\n return 'Unknown SQL Query';\n }\n\n return (\n sqlQuery\n // Remove comments first (they may contain newlines and extra spaces)\n .replace(/--.*$/gm, '') // Single line comments (multiline mode)\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Multi-line comments\n .replace(/;\\s*$/, '') // Remove trailing semicolons\n // Collapse whitespace to a single space (after removing comments)\n .replace(/\\s+/g, ' ')\n .trim() // Remove extra spaces and trim\n // Sanitize hex/binary literals before string literals\n .replace(/\\bX'[0-9A-Fa-f]*'/gi, '?') // Hex string literals\n .replace(/\\bB'[01]*'/gi, '?') // Binary string literals\n // Sanitize string literals (handles escaped quotes)\n .replace(/'(?:[^']|'')*'/g, '?')\n // Sanitize hex numbers\n .replace(/\\b0x[0-9A-Fa-f]+/gi, '?')\n // Sanitize boolean literals\n .replace(/\\b(?:TRUE|FALSE)\\b/gi, '?')\n // Sanitize numeric literals (preserve $n placeholders via negative lookbehind)\n .replace(/-?\\b\\d+\\.?\\d*[eE][+-]?\\d+\\b/g, '?') // Scientific notation\n .replace(/-?\\b\\d+\\.\\d+\\b/g, '?') // Decimals\n .replace(/-?\\.\\d+\\b/g, '?') // Decimals starting with dot\n .replace(/(?<!\\$)-?\\b\\d+\\b/g, '?') // Integers (NOT $n placeholders)\n // Collapse IN clauses for cardinality (both ? and $n variants)\n .replace(/\\bIN\\b\\s*\\(\\s*\\?(?:\\s*,\\s*\\?)*\\s*\\)/gi, 'IN (?)')\n .replace(/\\bIN\\b\\s*\\(\\s*\\$\\d+(?:\\s*,\\s*\\$\\d+)*\\s*\\)/gi, 'IN ($?)')\n );\n }\n\n /**\n * Fallback patch for Query.prototype.handle to instrument queries from pre-existing sql instances.\n * This catches queries from sql instances created BEFORE Sentry was initialized (CJS only).\n *\n * Note: Queries from pre-existing instances won't have connection context (database, host, port)\n * because the sql instance wasn't created through our instrumented wrapper.\n */\n private _patchQueryPrototype(moduleExports: {\n Query: {\n prototype: {\n handle: ((...args: unknown[]) => Promise<unknown>) & {\n __sentry_original__?: (...args: unknown[]) => Promise<unknown>;\n };\n };\n };\n }): typeof moduleExports {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n const originalHandle = moduleExports.Query.prototype.handle;\n\n moduleExports.Query.prototype.handle = async function (\n this: {\n resolve: unknown;\n reject: unknown;\n strings?: string[];\n },\n ...args: unknown[]\n ): Promise<unknown> {\n // Skip if this query came from an instrumented sql instance (already handled by wrapper)\n if ((this as Record<symbol, unknown>)[QUERY_FROM_INSTRUMENTED_SQL]) {\n return originalHandle.apply(this, args);\n }\n\n // Skip if we shouldn't create spans\n if (!self._shouldCreateSpans()) {\n return originalHandle.apply(this, args);\n }\n\n const fullQuery = self._reconstructQuery(this.strings);\n const sanitizedSqlQuery = self._sanitizeSqlQuery(fullQuery);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n addOriginToSpan(span, 'auto.db.postgresjs');\n\n span.setAttributes({\n [ATTR_DB_SYSTEM_NAME]: 'postgres',\n [ATTR_DB_QUERY_TEXT]: sanitizedSqlQuery,\n });\n\n // Note: No connection context available for pre-existing instances\n // because the sql instance wasn't created through our instrumented wrapper\n\n const config = self.getConfig();\n const { requestHook } = config;\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, undefined),\n e => {\n if (e) {\n span.setAttribute('sentry.hook.error', 'requestHook failed');\n DEBUG_BUILD && debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, e);\n }\n },\n true,\n );\n }\n\n // Wrap resolve to end span on success\n const originalResolve = this.resolve;\n this.resolve = new Proxy(originalResolve as (...args: unknown[]) => unknown, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n try {\n self._setOperationName(span, sanitizedSqlQuery, resolveArgs?.[0]?.command);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in resolve callback:', e);\n }\n return Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n },\n });\n\n // Wrap reject to end span on error\n const originalReject = this.reject;\n this.reject = new Proxy(originalReject as (...args: unknown[]) => unknown, {\n apply: (rejectTarget, rejectThisArg, rejectArgs: { message?: string; code?: string; name?: string }[]) => {\n try {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'unknown');\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'unknown');\n self._setOperationName(span, sanitizedSqlQuery);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in reject callback:', e);\n }\n return Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n },\n });\n\n try {\n return originalHandle.apply(this, args);\n } catch (e) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: e instanceof Error ? e.message : 'unknown_error',\n });\n span.end();\n throw e;\n }\n },\n );\n };\n\n // Store original for unpatch - must be set on the NEW patched function\n moduleExports.Query.prototype.handle.__sentry_original__ = originalHandle;\n\n return moduleExports;\n }\n\n /**\n * Restores the original Query.prototype.handle method.\n */\n private _unpatchQueryPrototype(moduleExports: {\n Query: {\n prototype: {\n handle: ((...args: unknown[]) => Promise<unknown>) & {\n __sentry_original__?: (...args: unknown[]) => Promise<unknown>;\n };\n };\n };\n }): typeof moduleExports {\n if (moduleExports.Query.prototype.handle.__sentry_original__) {\n moduleExports.Query.prototype.handle = moduleExports.Query.prototype.handle.__sentry_original__;\n }\n return moduleExports;\n }\n}\n\nconst _postgresJsIntegration = ((options?: PostgresJsInstrumentationConfig) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgresJs(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresJsIntegration()],\n * });\n * ```\n */\n\nexport const postgresJsIntegration = defineIntegration(_postgresJsIntegration);\n"],"names":["generateInstrumentOnce","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","DEBUG_BUILD","debug","InstrumentationNodeModuleFile","replaceExports","ATTR_DB_NAMESPACE","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","ATTR_DB_OPERATION_NAME","startSpanManual","addOriginToSpan","ATTR_DB_SYSTEM_NAME","ATTR_DB_QUERY_TEXT","safeExecuteInTheMiddle","SPAN_STATUS_ERROR","ATTR_DB_RESPONSE_STATUS_CODE","ATTR_ERROR_TYPE","trace","context","defineIntegration"],"mappings":";;;;;;;;;AAAA;AACA;;;AAgCA,MAAM,gBAAA,GAAmB,YAAY;AACrC,MAAM,kBAAA,GAAqB,CAAC,YAAY,CAAC;AACzC,MAAM,mBAAA,GAAsB,mDAAmD;;AAQ/E,MAAM,yBAAA,GAA4B,MAAM,CAAC,iCAAiC,CAAC;AAC3E,MAAM,sBAAsB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC;AACxE;AACA;AACA,MAAM,8BAA8B,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC;;AAiB7E,MAAM,oBAAA,GAAuBA,+BAAsB;AAC1D,EAAE,gBAAgB;AAClB,EAAE,CAAC,OAAO;AACV,IAAI,IAAI,yBAAyB,CAAC;AAClC,MAAM,iBAAiB,EAAE,OAAO,EAAE,iBAAA,IAAqB,IAAI;AAC3D,MAAM,WAAW,EAAE,OAAO,EAAE,WAAW;AACvC,KAAK,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkCC,mCAAmB,CAAkC;AACpG,GAAS,WAAW,CAAC,MAAM,EAAmC;AAC9D,IAAI,KAAK,CAAC,oBAAoB,EAAEC,gBAAW,EAAE,MAAM,CAAC;AACpD,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,GAAS,IAAI,GAAwC;AACrD,IAAI,MAAM,MAAA,GAAS,IAAIC,mDAAmC;AAC1D,MAAM,UAAU;AAChB,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,QAAQ,IAAI;AACZ,UAAU,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;AAC7C,QAAQ,CAAA,CAAE,OA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1
+ {"version":3,"file":"postgresjs.js","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"sourcesContent":["/* eslint-disable max-lines */\n// Instrumentation for https://github.com/porsager/postgres\n\nimport { context, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_RESPONSE_STATUS_CODE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n replaceExports,\n SDK_VERSION,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\nimport { DEBUG_BUILD } from '../../debug-build';\n\nconst INTEGRATION_NAME = 'PostgresJs';\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <4'];\nconst SQL_OPERATION_REGEX = /^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i;\n\ntype PostgresConnectionContext = {\n ATTR_DB_NAMESPACE?: string; // Database name\n ATTR_SERVER_ADDRESS?: string; // Hostname or IP address of the database server\n ATTR_SERVER_PORT?: string; // Port number of the database server\n};\n\nconst CONNECTION_CONTEXT_SYMBOL = Symbol('sentryPostgresConnectionContext');\nconst INSTRUMENTED_MARKER = Symbol.for('sentry.instrumented.postgresjs');\n// Marker to track if a query was created from an instrumented sql instance\n// This prevents double-spanning when both wrapper and prototype patches are active\nconst QUERY_FROM_INSTRUMENTED_SQL = Symbol.for('sentry.query.from.instrumented.sql');\n\ntype PostgresJsInstrumentationConfig = InstrumentationConfig & {\n /**\n * Whether to require a parent span for the instrumentation.\n * If set to true, the instrumentation will only create spans if there is a parent span\n * available in the current scope.\n * @default true\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the span before it is started.\n * This can be used to set additional attributes or modify the span in any way.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n};\n\nexport const instrumentPostgresJs = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: PostgresJsInstrumentationConfig) =>\n new PostgresJsInstrumentation({\n requireParentSpan: options?.requireParentSpan ?? true,\n requestHook: options?.requestHook,\n }),\n);\n\n/**\n * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n * This instrumentation captures postgresjs queries and their attributes.\n *\n * Uses internal Sentry patching patterns to support both CommonJS and ESM environments.\n */\nexport class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {\n public constructor(config: PostgresJsInstrumentationConfig) {\n super('sentry-postgres-js', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by patching the postgres module.\n * Uses two complementary approaches:\n * 1. Main function wrapper: instruments sql instances created AFTER instrumentation is set up (CJS + ESM)\n * 2. Query.prototype patch: fallback for sql instances created BEFORE instrumentation (CJS only)\n */\n public init(): InstrumentationNodeModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'postgres',\n SUPPORTED_VERSIONS,\n exports => {\n try {\n return this._patchPostgres(exports);\n } catch (e) {\n DEBUG_BUILD && debug.error('Failed to patch postgres module:', e);\n return exports;\n }\n },\n exports => exports,\n );\n\n // Add fallback Query.prototype patching for pre-existing sql instances (CJS only)\n // This catches queries from sql instances created before Sentry was initialized\n ['src', 'cf/src', 'cjs/src'].forEach(path => {\n module.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/query.js`,\n SUPPORTED_VERSIONS,\n this._patchQueryPrototype.bind(this),\n this._unpatchQueryPrototype.bind(this),\n ),\n );\n });\n\n return module;\n }\n\n /**\n * Patches the postgres module by wrapping the main export function.\n * This intercepts the creation of sql instances and instruments them.\n */\n private _patchPostgres(exports: { [key: string]: unknown }): { [key: string]: unknown } {\n // In CJS: exports is the function itself\n // In ESM: exports.default is the function\n const isFunction = typeof exports === 'function';\n const Original = isFunction ? exports : exports.default;\n\n if (typeof Original !== 'function') {\n DEBUG_BUILD && debug.warn('postgres module does not export a function. Skipping instrumentation.');\n return exports;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n const WrappedPostgres = function (this: unknown, ...args: unknown[]): unknown {\n const sql = Reflect.construct(Original as (...args: unknown[]) => unknown, args);\n\n // Validate that construction succeeded and returned a valid function object\n if (!sql || typeof sql !== 'function') {\n DEBUG_BUILD && debug.warn('postgres() did not return a valid instance');\n return sql;\n }\n\n return self._instrumentSqlInstance(sql);\n };\n\n Object.setPrototypeOf(WrappedPostgres, Original);\n Object.setPrototypeOf(WrappedPostgres.prototype, (Original as { prototype: object }).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(WrappedPostgres, key, descriptor);\n }\n }\n }\n\n // For CJS: the exports object IS the function, so return the wrapped function\n // For ESM: replace the default export\n if (isFunction) {\n return WrappedPostgres as unknown as { [key: string]: unknown };\n } else {\n replaceExports(exports, 'default', WrappedPostgres);\n return exports;\n }\n }\n\n /**\n * Wraps query-returning methods (unsafe, file) to ensure their queries are instrumented.\n */\n private _wrapQueryMethod(\n original: (...args: unknown[]) => unknown,\n target: unknown,\n proxiedSql: unknown,\n ): (...args: unknown[]) => unknown {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n return function (this: unknown, ...args: unknown[]): unknown {\n const query = Reflect.apply(original, target, args);\n\n if (query && typeof query === 'object' && 'handle' in query) {\n self._wrapSingleQueryHandle(query as { handle: unknown; strings?: string[] }, proxiedSql);\n }\n\n return query;\n };\n }\n\n /**\n * Wraps callback-based methods (begin, reserve) to recursively instrument Sql instances.\n * Note: These methods can also be used as tagged templates, which we pass through unchanged.\n *\n * Savepoint is not wrapped to avoid complex nested transaction instrumentation issues.\n * Queries within savepoint callbacks are still instrumented through the parent transaction's Sql instance.\n */\n private _wrapCallbackMethod(\n original: (...args: unknown[]) => unknown,\n target: unknown,\n parentSqlInstance: unknown,\n ): (...args: unknown[]) => unknown {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n return function (this: unknown, ...args: unknown[]): unknown {\n // Extract parent context to propagate to child instances\n const parentContext = (parentSqlInstance as Record<symbol, unknown>)[CONNECTION_CONTEXT_SYMBOL] as\n | PostgresConnectionContext\n | undefined;\n\n // Check if this is a callback-based call by verifying the last argument is a function\n const isCallbackBased = typeof args[args.length - 1] === 'function';\n\n if (!isCallbackBased) {\n // Not a callback-based call - could be tagged template or promise-based\n const result = Reflect.apply(original, target, args);\n // If result is a Promise (e.g., reserve() without callback), instrument the resolved Sql instance\n if (result && typeof (result as Promise<unknown>).then === 'function') {\n return (result as Promise<unknown>).then((sqlInstance: unknown) => {\n return self._instrumentSqlInstance(sqlInstance, parentContext);\n });\n }\n return result;\n }\n\n // Callback-based call: wrap the callback to instrument the Sql instance\n const callback = (args.length === 1 ? args[0] : args[1]) as (sql: unknown) => unknown;\n const wrappedCallback = function (sqlInstance: unknown): unknown {\n const instrumentedSql = self._instrumentSqlInstance(sqlInstance, parentContext);\n return callback(instrumentedSql);\n };\n\n const newArgs = args.length === 1 ? [wrappedCallback] : [args[0], wrappedCallback];\n return Reflect.apply(original, target, newArgs);\n };\n }\n\n /**\n * Sets connection context attributes on a span.\n */\n private _setConnectionAttributes(span: Span, connectionContext: PostgresConnectionContext | undefined): void {\n if (!connectionContext) {\n return;\n }\n if (connectionContext.ATTR_DB_NAMESPACE) {\n span.setAttribute(ATTR_DB_NAMESPACE, connectionContext.ATTR_DB_NAMESPACE);\n }\n if (connectionContext.ATTR_SERVER_ADDRESS) {\n span.setAttribute(ATTR_SERVER_ADDRESS, connectionContext.ATTR_SERVER_ADDRESS);\n }\n if (connectionContext.ATTR_SERVER_PORT !== undefined) {\n // Port is stored as string in PostgresConnectionContext for requestHook backwards compatibility,\n // but OTEL semantic conventions expect port as a number for span attributes\n const portNumber = parseInt(connectionContext.ATTR_SERVER_PORT, 10);\n if (!isNaN(portNumber)) {\n span.setAttribute(ATTR_SERVER_PORT, portNumber);\n }\n }\n }\n\n /**\n * Extracts DB operation name from SQL query and sets it on the span.\n */\n private _setOperationName(span: Span, sanitizedQuery: string | undefined, command?: string): void {\n if (command) {\n span.setAttribute(ATTR_DB_OPERATION_NAME, command);\n return;\n }\n // Fallback: extract operation from the SQL query\n const operationMatch = sanitizedQuery?.match(SQL_OPERATION_REGEX);\n if (operationMatch?.[1]) {\n span.setAttribute(ATTR_DB_OPERATION_NAME, operationMatch[1].toUpperCase());\n }\n }\n\n /**\n * Extracts and stores connection context from sql.options.\n */\n private _attachConnectionContext(sql: unknown, proxiedSql: Record<symbol, unknown>): void {\n const sqlInstance = sql as { options?: { host?: string[]; port?: number[]; database?: string } };\n if (!sqlInstance.options || typeof sqlInstance.options !== 'object') {\n return;\n }\n\n const opts = sqlInstance.options;\n // postgres.js stores parsed options with host and port as arrays\n // The library defaults to 'localhost' and 5432 if not specified, but we're defensive here\n const host = opts.host?.[0] || 'localhost';\n const port = opts.port?.[0] || 5432;\n\n const connectionContext: PostgresConnectionContext = {\n ATTR_DB_NAMESPACE: typeof opts.database === 'string' && opts.database !== '' ? opts.database : undefined,\n ATTR_SERVER_ADDRESS: host,\n ATTR_SERVER_PORT: String(port),\n };\n\n proxiedSql[CONNECTION_CONTEXT_SYMBOL] = connectionContext;\n }\n\n /**\n * Instruments a sql instance by wrapping its query execution methods.\n */\n private _instrumentSqlInstance(sql: unknown, parentConnectionContext?: PostgresConnectionContext): unknown {\n // Check if already instrumented to prevent double-wrapping\n // Using Symbol.for() ensures the marker survives proxying\n if ((sql as Record<symbol, unknown>)[INSTRUMENTED_MARKER]) {\n return sql;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n // Wrap the sql function to intercept query creation\n const proxiedSql: unknown = new Proxy(sql as (...args: unknown[]) => unknown, {\n apply(target, thisArg, argumentsList: unknown[]) {\n const query = Reflect.apply(target, thisArg, argumentsList);\n\n if (query && typeof query === 'object' && 'handle' in query) {\n self._wrapSingleQueryHandle(query as { handle: unknown; strings?: string[] }, proxiedSql);\n }\n\n return query;\n },\n get(target, prop) {\n const original = (target as unknown as Record<string | symbol, unknown>)[prop];\n\n if (typeof prop !== 'string' || typeof original !== 'function') {\n return original;\n }\n\n // Wrap methods that return PendingQuery objects (unsafe, file)\n if (prop === 'unsafe' || prop === 'file') {\n return self._wrapQueryMethod(original as (...args: unknown[]) => unknown, target, proxiedSql);\n }\n\n // Wrap begin and reserve (not savepoint to avoid duplicate spans)\n if (prop === 'begin' || prop === 'reserve') {\n return self._wrapCallbackMethod(original as (...args: unknown[]) => unknown, target, proxiedSql);\n }\n\n return original;\n },\n });\n\n // Use provided parent context if available, otherwise extract from sql.options\n if (parentConnectionContext) {\n (proxiedSql as Record<symbol, unknown>)[CONNECTION_CONTEXT_SYMBOL] = parentConnectionContext;\n } else {\n this._attachConnectionContext(sql, proxiedSql as Record<symbol, unknown>);\n }\n\n // Mark both the original and proxy as instrumented to prevent double-wrapping\n // The proxy might be passed to other methods, or the original\n // might be accessed directly, so we need to mark both\n (sql as Record<symbol, unknown>)[INSTRUMENTED_MARKER] = true;\n (proxiedSql as Record<symbol, unknown>)[INSTRUMENTED_MARKER] = true;\n\n return proxiedSql;\n }\n\n /**\n * Wraps a single query's handle method to create spans.\n */\n private _wrapSingleQueryHandle(\n query: { handle: unknown; strings?: string[]; __sentryWrapped?: boolean },\n sqlInstance: unknown,\n ): void {\n // Prevent double wrapping - check if the handle itself is already wrapped\n if ((query.handle as { __sentryWrapped?: boolean })?.__sentryWrapped) {\n return;\n }\n\n // Mark this query as coming from an instrumented sql instance\n // This prevents the Query.prototype fallback patch from double-spanning\n (query as Record<symbol, unknown>)[QUERY_FROM_INSTRUMENTED_SQL] = true;\n\n const originalHandle = query.handle as (...args: unknown[]) => Promise<unknown>;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n\n // IMPORTANT: We must replace the handle function directly, not use a Proxy,\n // because Query.then() internally calls this.handle(), which would bypass a Proxy wrapper.\n const wrappedHandle = async function (this: unknown, ...args: unknown[]): Promise<unknown> {\n if (!self._shouldCreateSpans()) {\n return originalHandle.apply(this, args);\n }\n\n const fullQuery = self._reconstructQuery(query.strings);\n const sanitizedSqlQuery = self._sanitizeSqlQuery(fullQuery);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n addOriginToSpan(span, 'auto.db.postgresjs');\n\n span.setAttributes({\n [ATTR_DB_SYSTEM_NAME]: 'postgres',\n [ATTR_DB_QUERY_TEXT]: sanitizedSqlQuery,\n });\n\n const connectionContext = sqlInstance\n ? ((sqlInstance as Record<symbol, unknown>)[CONNECTION_CONTEXT_SYMBOL] as\n | PostgresConnectionContext\n | undefined)\n : undefined;\n\n self._setConnectionAttributes(span, connectionContext);\n\n const config = self.getConfig();\n const { requestHook } = config;\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, connectionContext),\n e => {\n if (e) {\n span.setAttribute('sentry.hook.error', 'requestHook failed');\n DEBUG_BUILD && debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, e);\n }\n },\n true,\n );\n }\n\n const queryWithCallbacks = this as {\n resolve: unknown;\n reject: unknown;\n };\n\n queryWithCallbacks.resolve = new Proxy(queryWithCallbacks.resolve as (...args: unknown[]) => unknown, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n try {\n self._setOperationName(span, sanitizedSqlQuery, resolveArgs?.[0]?.command);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in resolve callback:', e);\n }\n\n return Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n },\n });\n\n queryWithCallbacks.reject = new Proxy(queryWithCallbacks.reject as (...args: unknown[]) => unknown, {\n apply: (rejectTarget, rejectThisArg, rejectArgs: { message?: string; code?: string; name?: string }[]) => {\n try {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'unknown');\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'unknown');\n\n self._setOperationName(span, sanitizedSqlQuery);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in reject callback:', e);\n }\n return Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n },\n });\n\n // Handle synchronous errors that might occur before promise is created\n try {\n return originalHandle.apply(this, args);\n } catch (e) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: e instanceof Error ? e.message : 'unknown_error',\n });\n span.end();\n throw e;\n }\n },\n );\n };\n\n (wrappedHandle as { __sentryWrapped?: boolean }).__sentryWrapped = true;\n query.handle = wrappedHandle;\n }\n\n /**\n * Determines whether a span should be created based on the current context.\n * If `requireParentSpan` is set to true in the configuration, a span will\n * only be created if there is a parent span available.\n */\n private _shouldCreateSpans(): boolean {\n const config = this.getConfig();\n const hasParentSpan = trace.getSpan(context.active()) !== undefined;\n return hasParentSpan || !config.requireParentSpan;\n }\n\n /**\n * Reconstructs the full SQL query from template strings with PostgreSQL placeholders.\n *\n * For sql`SELECT * FROM users WHERE id = ${123} AND name = ${'foo'}`:\n * strings = [\"SELECT * FROM users WHERE id = \", \" AND name = \", \"\"]\n * returns: \"SELECT * FROM users WHERE id = $1 AND name = $2\"\n */\n private _reconstructQuery(strings: string[] | undefined): string | undefined {\n if (!strings?.length) {\n return undefined;\n }\n if (strings.length === 1) {\n return strings[0] || undefined;\n }\n // Join template parts with PostgreSQL placeholders ($1, $2, etc.)\n return strings.reduce((acc, str, i) => (i === 0 ? str : `${acc}$${i}${str}`), '');\n }\n\n /**\n * Sanitize SQL query as per the OTEL semantic conventions\n * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext\n *\n * PostgreSQL $n placeholders are preserved per OTEL spec - they're parameterized queries,\n * not sensitive literals. Only actual values (strings, numbers, booleans) are sanitized.\n */\n private _sanitizeSqlQuery(sqlQuery: string | undefined): string {\n if (!sqlQuery) {\n return 'Unknown SQL Query';\n }\n\n return (\n sqlQuery\n // Remove comments first (they may contain newlines and extra spaces)\n .replace(/--.*$/gm, '') // Single line comments (multiline mode)\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Multi-line comments\n .replace(/;\\s*$/, '') // Remove trailing semicolons\n // Collapse whitespace to a single space (after removing comments)\n .replace(/\\s+/g, ' ')\n .trim() // Remove extra spaces and trim\n // Sanitize hex/binary literals before string literals\n .replace(/\\bX'[0-9A-Fa-f]*'/gi, '?') // Hex string literals\n .replace(/\\bB'[01]*'/gi, '?') // Binary string literals\n // Sanitize string literals (handles escaped quotes)\n .replace(/'(?:[^']|'')*'/g, '?')\n // Sanitize hex numbers\n .replace(/\\b0x[0-9A-Fa-f]+/gi, '?')\n // Sanitize boolean literals\n .replace(/\\b(?:TRUE|FALSE)\\b/gi, '?')\n // Sanitize numeric literals (preserve $n placeholders via negative lookbehind)\n .replace(/-?\\b\\d+\\.?\\d*[eE][+-]?\\d+\\b/g, '?') // Scientific notation\n .replace(/-?\\b\\d+\\.\\d+\\b/g, '?') // Decimals\n .replace(/-?\\.\\d+\\b/g, '?') // Decimals starting with dot\n .replace(/(?<!\\$)-?\\b\\d+\\b/g, '?') // Integers (NOT $n placeholders)\n // Collapse IN clauses for cardinality (both ? and $n variants)\n .replace(/\\bIN\\b\\s*\\(\\s*\\?(?:\\s*,\\s*\\?)*\\s*\\)/gi, 'IN (?)')\n .replace(/\\bIN\\b\\s*\\(\\s*\\$\\d+(?:\\s*,\\s*\\$\\d+)*\\s*\\)/gi, 'IN ($?)')\n );\n }\n\n /**\n * Fallback patch for Query.prototype.handle to instrument queries from pre-existing sql instances.\n * This catches queries from sql instances created BEFORE Sentry was initialized (CJS only).\n *\n * Note: Queries from pre-existing instances won't have connection context (database, host, port)\n * because the sql instance wasn't created through our instrumented wrapper.\n */\n private _patchQueryPrototype(moduleExports: {\n Query: {\n prototype: {\n handle: ((...args: unknown[]) => Promise<unknown>) & {\n __sentry_original__?: (...args: unknown[]) => Promise<unknown>;\n };\n };\n };\n }): typeof moduleExports {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n const originalHandle = moduleExports.Query.prototype.handle;\n\n moduleExports.Query.prototype.handle = async function (\n this: {\n resolve: unknown;\n reject: unknown;\n strings?: string[];\n },\n ...args: unknown[]\n ): Promise<unknown> {\n // Skip if this query came from an instrumented sql instance (already handled by wrapper)\n if ((this as Record<symbol, unknown>)[QUERY_FROM_INSTRUMENTED_SQL]) {\n return originalHandle.apply(this, args);\n }\n\n // Skip if we shouldn't create spans\n if (!self._shouldCreateSpans()) {\n return originalHandle.apply(this, args);\n }\n\n const fullQuery = self._reconstructQuery(this.strings);\n const sanitizedSqlQuery = self._sanitizeSqlQuery(fullQuery);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n addOriginToSpan(span, 'auto.db.postgresjs');\n\n span.setAttributes({\n [ATTR_DB_SYSTEM_NAME]: 'postgres',\n [ATTR_DB_QUERY_TEXT]: sanitizedSqlQuery,\n });\n\n // Note: No connection context available for pre-existing instances\n // because the sql instance wasn't created through our instrumented wrapper\n\n const config = self.getConfig();\n const { requestHook } = config;\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, undefined),\n e => {\n if (e) {\n span.setAttribute('sentry.hook.error', 'requestHook failed');\n DEBUG_BUILD && debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, e);\n }\n },\n true,\n );\n }\n\n // Wrap resolve to end span on success\n const originalResolve = this.resolve;\n this.resolve = new Proxy(originalResolve as (...args: unknown[]) => unknown, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n try {\n self._setOperationName(span, sanitizedSqlQuery, resolveArgs?.[0]?.command);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in resolve callback:', e);\n }\n return Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n },\n });\n\n // Wrap reject to end span on error\n const originalReject = this.reject;\n this.reject = new Proxy(originalReject as (...args: unknown[]) => unknown, {\n apply: (rejectTarget, rejectThisArg, rejectArgs: { message?: string; code?: string; name?: string }[]) => {\n try {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'unknown');\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'unknown');\n self._setOperationName(span, sanitizedSqlQuery);\n span.end();\n } catch (e) {\n DEBUG_BUILD && debug.error('Error ending span in reject callback:', e);\n }\n return Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n },\n });\n\n try {\n return originalHandle.apply(this, args);\n } catch (e) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: e instanceof Error ? e.message : 'unknown_error',\n });\n span.end();\n throw e;\n }\n },\n );\n };\n\n // Store original for unpatch - must be set on the NEW patched function\n moduleExports.Query.prototype.handle.__sentry_original__ = originalHandle;\n\n return moduleExports;\n }\n\n /**\n * Restores the original Query.prototype.handle method.\n */\n private _unpatchQueryPrototype(moduleExports: {\n Query: {\n prototype: {\n handle: ((...args: unknown[]) => Promise<unknown>) & {\n __sentry_original__?: (...args: unknown[]) => Promise<unknown>;\n };\n };\n };\n }): typeof moduleExports {\n if (moduleExports.Query.prototype.handle.__sentry_original__) {\n moduleExports.Query.prototype.handle = moduleExports.Query.prototype.handle.__sentry_original__;\n }\n return moduleExports;\n }\n}\n\nconst _postgresJsIntegration = ((options?: PostgresJsInstrumentationConfig) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgresJs(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresJsIntegration()],\n * });\n * ```\n */\n\nexport const postgresJsIntegration = defineIntegration(_postgresJsIntegration);\n"],"names":["generateInstrumentOnce","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","exports","DEBUG_BUILD","debug","InstrumentationNodeModuleFile","replaceExports","ATTR_DB_NAMESPACE","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","ATTR_DB_OPERATION_NAME","startSpanManual","addOriginToSpan","ATTR_DB_SYSTEM_NAME","ATTR_DB_QUERY_TEXT","safeExecuteInTheMiddle","SPAN_STATUS_ERROR","ATTR_DB_RESPONSE_STATUS_CODE","ATTR_ERROR_TYPE","trace","context","defineIntegration"],"mappings":";;;;;;;;;AAAA;AACA;;;AAgCA,MAAM,gBAAA,GAAmB,YAAY;AACrC,MAAM,kBAAA,GAAqB,CAAC,YAAY,CAAC;AACzC,MAAM,mBAAA,GAAsB,mDAAmD;;AAQ/E,MAAM,yBAAA,GAA4B,MAAM,CAAC,iCAAiC,CAAC;AAC3E,MAAM,sBAAsB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC;AACxE;AACA;AACA,MAAM,8BAA8B,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC;;AAiB7E,MAAM,oBAAA,GAAuBA,+BAAsB;AAC1D,EAA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AAEA,IAAA,OAAA,aAAA;AACA,EAAA;;AAEA;AACA;AACA;AACA,GAAA,sBAAA,CAAA;;AAQA,EAAA;AACA,IAAA,IAAA,aAAA,CAAA,KAAA,CAAA,SAAA,CAAA,MAAA,CAAA,mBAAA,EAAA;AACA,MAAA,aAAA,CAAA,KAAA,CAAA,SAAA,CAAA,MAAA,GAAA,aAAA,CAAA,KAAA,CAAA,SAAA,CAAA,MAAA,CAAA,mBAAA;AACA,IAAA;AACA,IAAA,OAAA,aAAA;AACA,EAAA;AACA;;AAEA,MAAA,sBAAA,IAAA,CAAA,OAAA,KAAA;AACA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,gBAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAA,oBAAA,CAAA,OAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAA,qBAAA,GAAAK,sBAAA,CAAA,sBAAA;;;;;;"}
@@ -15,6 +15,7 @@ const INSTRUMENTED_METHODS = [
15
15
  'streamObject',
16
16
  'embed',
17
17
  'embedMany',
18
+ 'rerank',
18
19
  ] ;
19
20
 
20
21
  function isToolError(obj) {
@@ -226,7 +227,10 @@ class SentryVercelAiInstrumentation extends instrumentation.InstrumentationBase
226
227
  if (Object.prototype.toString.call(moduleExports) === '[object Module]') {
227
228
  // In ESM we take the usual route and just replace the exports we want to instrument
228
229
  for (const method of INSTRUMENTED_METHODS) {
229
- moduleExports[method] = generatePatch(moduleExports[method]);
230
+ // Skip methods that don't exist in this version of the AI SDK (e.g., rerank was added in v6)
231
+ if (moduleExports[method] != null) {
232
+ moduleExports[method] = generatePatch(moduleExports[method]);
233
+ }
230
234
  }
231
235
 
232
236
  return moduleExports;
@@ -234,7 +238,10 @@ class SentryVercelAiInstrumentation extends instrumentation.InstrumentationBase
234
238
  // In CJS we can't replace the exports in the original module because they
235
239
  // don't have setters, so we create a new object with the same properties
236
240
  const patchedModuleExports = INSTRUMENTED_METHODS.reduce((acc, curr) => {
237
- acc[curr] = generatePatch(moduleExports[curr]);
241
+ // Skip methods that don't exist in this version of the AI SDK (e.g., rerank was added in v6)
242
+ if (moduleExports[curr] != null) {
243
+ acc[curr] = generatePatch(moduleExports[curr]);
244
+ }
238
245
  return acc;
239
246
  }, {} );
240
247
 
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/vercelai/instrumentation.ts"],"sourcesContent":["import type { InstrumentationConfig, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport type { Span } from '@sentry/core';\nimport {\n _INTERNAL_cleanupToolCallSpan,\n _INTERNAL_getSpanForToolCallId,\n addNonEnumerableProperty,\n captureException,\n getActiveSpan,\n getClient,\n handleCallbackErrors,\n SDK_VERSION,\n withScope,\n} from '@sentry/core';\nimport { INTEGRATION_NAME } from './constants';\nimport type { TelemetrySettings, VercelAiIntegration } from './types';\n\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <7'];\n\n// List of patched methods\n// From: https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#collected-data\nconst INSTRUMENTED_METHODS = [\n 'generateText',\n 'streamText',\n 'generateObject',\n 'streamObject',\n 'embed',\n 'embedMany',\n] as const;\n\ninterface MethodFirstArg extends Record<string, unknown> {\n experimental_telemetry?: TelemetrySettings;\n}\n\ntype MethodArgs = [MethodFirstArg, ...unknown[]];\n\ntype PatchedModuleExports = Record<(typeof INSTRUMENTED_METHODS)[number], (...args: MethodArgs) => unknown> &\n Record<string, unknown>;\n\ninterface RecordingOptions {\n recordInputs?: boolean;\n recordOutputs?: boolean;\n}\n\ninterface ToolError {\n type: 'tool-error' | 'tool-result' | 'tool-call';\n toolCallId: string;\n toolName: string;\n input?: {\n [key: string]: unknown;\n };\n error: Error;\n dynamic?: boolean;\n}\n\nfunction isToolError(obj: unknown): obj is ToolError {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n\n const candidate = obj as Record<string, unknown>;\n return (\n 'type' in candidate &&\n 'error' in candidate &&\n 'toolName' in candidate &&\n 'toolCallId' in candidate &&\n candidate.type === 'tool-error' &&\n candidate.error instanceof Error\n );\n}\n\n/**\n * Check for tool errors in the result and capture them\n * Tool errors are not rejected in Vercel V5, it is added as metadata to the result content\n */\nfunction checkResultForToolErrors(result: unknown): void {\n if (typeof result !== 'object' || result === null || !('content' in result)) {\n return;\n }\n\n const resultObj = result as { content: Array<object> };\n if (!Array.isArray(resultObj.content)) {\n return;\n }\n\n for (const item of resultObj.content) {\n if (isToolError(item)) {\n // Try to get the span associated with this tool call ID\n const associatedSpan = _INTERNAL_getSpanForToolCallId(item.toolCallId) as Span;\n\n if (associatedSpan) {\n // We have the span, so link the error using span and trace IDs from the span\n const spanContext = associatedSpan.spanContext();\n\n withScope(scope => {\n // Set the span and trace context for proper linking\n scope.setContext('trace', {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n });\n\n scope.setTag('vercel.ai.tool.name', item.toolName);\n scope.setTag('vercel.ai.tool.callId', item.toolCallId);\n\n scope.setLevel('error');\n\n captureException(item.error, {\n mechanism: {\n type: 'auto.vercelai.otel',\n handled: false,\n },\n });\n });\n\n // Clean up the span mapping since we've processed this tool error\n // We won't get multiple { type: 'tool-error' } parts for the same toolCallId.\n _INTERNAL_cleanupToolCallSpan(item.toolCallId);\n } else {\n // Fallback: capture without span linking\n withScope(scope => {\n scope.setTag('vercel.ai.tool.name', item.toolName);\n scope.setTag('vercel.ai.tool.callId', item.toolCallId);\n scope.setLevel('error');\n\n captureException(item.error, {\n mechanism: {\n type: 'auto.vercelai.otel',\n handled: false,\n },\n });\n });\n }\n }\n }\n}\n\n/**\n * Determines whether to record inputs and outputs for Vercel AI telemetry based on the configuration hierarchy.\n *\n * The order of precedence is:\n * 1. The vercel ai integration options\n * 2. The experimental_telemetry options in the vercel ai method calls\n * 3. When telemetry is explicitly enabled (isEnabled: true), default to recording\n * 4. Otherwise, use the sendDefaultPii option from client options\n */\nexport function determineRecordingSettings(\n integrationRecordingOptions: RecordingOptions | undefined,\n methodTelemetryOptions: RecordingOptions,\n telemetryExplicitlyEnabled: boolean | undefined,\n defaultRecordingEnabled: boolean,\n): { recordInputs: boolean; recordOutputs: boolean } {\n const recordInputs =\n integrationRecordingOptions?.recordInputs !== undefined\n ? integrationRecordingOptions.recordInputs\n : methodTelemetryOptions.recordInputs !== undefined\n ? methodTelemetryOptions.recordInputs\n : telemetryExplicitlyEnabled === true\n ? true // When telemetry is explicitly enabled, default to recording inputs\n : defaultRecordingEnabled;\n\n const recordOutputs =\n integrationRecordingOptions?.recordOutputs !== undefined\n ? integrationRecordingOptions.recordOutputs\n : methodTelemetryOptions.recordOutputs !== undefined\n ? methodTelemetryOptions.recordOutputs\n : telemetryExplicitlyEnabled === true\n ? true // When telemetry is explicitly enabled, default to recording inputs\n : defaultRecordingEnabled;\n\n return { recordInputs, recordOutputs };\n}\n\n/**\n * This detects is added by the Sentry Vercel AI Integration to detect if the integration should\n * be enabled.\n *\n * It also patches the `ai` module to enable Vercel AI telemetry automatically for all methods.\n */\nexport class SentryVercelAiInstrumentation extends InstrumentationBase {\n private _isPatched = false;\n private _callbacks: (() => void)[] = [];\n\n public constructor(config: InstrumentationConfig = {}) {\n super('@sentry/instrumentation-vercel-ai', 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('ai', SUPPORTED_VERSIONS, this._patch.bind(this));\n return module;\n }\n\n /**\n * Call the provided callback when the module is patched.\n * If it has already been patched, the callback will be called immediately.\n */\n public callWhenPatched(callback: () => void): void {\n if (this._isPatched) {\n callback();\n } else {\n this._callbacks.push(callback);\n }\n }\n\n /**\n * Patches module exports to enable Vercel AI telemetry.\n */\n private _patch(moduleExports: PatchedModuleExports): unknown {\n this._isPatched = true;\n\n this._callbacks.forEach(callback => callback());\n this._callbacks = [];\n\n const generatePatch = <T extends (...args: MethodArgs) => unknown>(originalMethod: T): T => {\n return new Proxy(originalMethod, {\n apply: (target, thisArg, args: MethodArgs) => {\n const existingExperimentalTelemetry = args[0].experimental_telemetry || {};\n const isEnabled = existingExperimentalTelemetry.isEnabled;\n\n const client = getClient();\n const integration = client?.getIntegrationByName<VercelAiIntegration>(INTEGRATION_NAME);\n const integrationOptions = integration?.options;\n const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;\n\n const { recordInputs, recordOutputs } = determineRecordingSettings(\n integrationOptions,\n existingExperimentalTelemetry,\n isEnabled,\n shouldRecordInputsAndOutputs,\n );\n\n args[0].experimental_telemetry = {\n ...existingExperimentalTelemetry,\n isEnabled: isEnabled !== undefined ? isEnabled : true,\n recordInputs,\n recordOutputs,\n };\n\n return handleCallbackErrors(\n () => Reflect.apply(target, thisArg, args),\n error => {\n // This error bubbles up to unhandledrejection handler (if not handled before),\n // where we do not know the active span anymore\n // So to circumvent this, we set the active span on the error object\n // which is picked up by the unhandledrejection handler\n if (error && typeof error === 'object') {\n addNonEnumerableProperty(error, '_sentry_active_span', getActiveSpan());\n }\n },\n () => {},\n result => {\n checkResultForToolErrors(result);\n },\n );\n },\n });\n };\n\n // Is this an ESM module?\n // https://tc39.es/ecma262/#sec-module-namespace-objects\n if (Object.prototype.toString.call(moduleExports) === '[object Module]') {\n // In ESM we take the usual route and just replace the exports we want to instrument\n for (const method of INSTRUMENTED_METHODS) {\n moduleExports[method] = generatePatch(moduleExports[method]);\n }\n\n return moduleExports;\n } else {\n // In CJS we can't replace the exports in the original module because they\n // don't have setters, so we create a new object with the same properties\n const patchedModuleExports = INSTRUMENTED_METHODS.reduce((acc, curr) => {\n acc[curr] = generatePatch(moduleExports[curr]);\n return acc;\n }, {} as PatchedModuleExports);\n\n return { ...moduleExports, ...patchedModuleExports };\n }\n }\n}\n"],"names":["_INTERNAL_getSpanForToolCallId","withScope","captureException","_INTERNAL_cleanupToolCallSpan","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","getClient","INTEGRATION_NAME","handleCallbackErrors","addNonEnumerableProperty","getActiveSpan"],"mappings":";;;;;;AAiBA,MAAM,kBAAA,GAAqB,CAAC,YAAY,CAAC;;AAEzC;AACA;AACA,MAAM,uBAAuB;AAC7B,EAAE,cAAc;AAChB,EAAE,YAAY;AACd,EAAE,gBAAgB;AAClB,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,WAAW;AACb,CAAA;;AA2BA,SAAS,WAAW,CAAC,GAAG,EAA6B;AACrD,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,IAAI,EAAE;AAC/C,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,GAAA;AACpB,EAAE;AACF,IAAI,MAAA,IAAU,SAAA;AACd,IAAI,OAAA,IAAW,SAAA;AACf,IAAI,UAAA,IAAc,SAAA;AAClB,IAAI,YAAA,IAAgB,SAAA;AACpB,IAAI,SAAS,CAAC,IAAA,KAAS,YAAA;AACvB,IAAI,SAAS,CAAC,KAAA,YAAiB;AAC/B;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,MAAM,EAAiB;AACzD,EAAE,IAAI,OAAO,MAAA,KAAW,YAAY,MAAA,KAAW,IAAA,IAAQ,EAAE,aAAa,MAAM,CAAC,EAAE;AAC/E,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,MAAA;AACpB,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;AACzC,IAAI;AACJ,EAAE;;AAEF,EAAE,KAAK,MAAM,IAAA,IAAQ,SAAS,CAAC,OAAO,EAAE;AACxC,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;AAC3B;AACA,MAAM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Aa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACtD,QAAQ,OAAO,GAAG;AAClB,MAAM,CAAC,EAAE,EAAC,EAA0B;;AAEpC,MAAM,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,sBAAsB;AAC1D,IAAI;AACJ,EAAE;AACF;;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/vercelai/instrumentation.ts"],"sourcesContent":["import type { InstrumentationConfig, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport type { Span } from '@sentry/core';\nimport {\n _INTERNAL_cleanupToolCallSpan,\n _INTERNAL_getSpanForToolCallId,\n addNonEnumerableProperty,\n captureException,\n getActiveSpan,\n getClient,\n handleCallbackErrors,\n SDK_VERSION,\n withScope,\n} from '@sentry/core';\nimport { INTEGRATION_NAME } from './constants';\nimport type { TelemetrySettings, VercelAiIntegration } from './types';\n\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <7'];\n\n// List of patched methods\n// From: https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#collected-data\nconst INSTRUMENTED_METHODS = [\n 'generateText',\n 'streamText',\n 'generateObject',\n 'streamObject',\n 'embed',\n 'embedMany',\n 'rerank',\n] as const;\n\ninterface MethodFirstArg extends Record<string, unknown> {\n experimental_telemetry?: TelemetrySettings;\n}\n\ntype MethodArgs = [MethodFirstArg, ...unknown[]];\n\ntype PatchedModuleExports = Record<(typeof INSTRUMENTED_METHODS)[number], (...args: MethodArgs) => unknown> &\n Record<string, unknown>;\n\ninterface RecordingOptions {\n recordInputs?: boolean;\n recordOutputs?: boolean;\n}\n\ninterface ToolError {\n type: 'tool-error' | 'tool-result' | 'tool-call';\n toolCallId: string;\n toolName: string;\n input?: {\n [key: string]: unknown;\n };\n error: Error;\n dynamic?: boolean;\n}\n\nfunction isToolError(obj: unknown): obj is ToolError {\n if (typeof obj !== 'object' || obj === null) {\n return false;\n }\n\n const candidate = obj as Record<string, unknown>;\n return (\n 'type' in candidate &&\n 'error' in candidate &&\n 'toolName' in candidate &&\n 'toolCallId' in candidate &&\n candidate.type === 'tool-error' &&\n candidate.error instanceof Error\n );\n}\n\n/**\n * Check for tool errors in the result and capture them\n * Tool errors are not rejected in Vercel V5, it is added as metadata to the result content\n */\nfunction checkResultForToolErrors(result: unknown): void {\n if (typeof result !== 'object' || result === null || !('content' in result)) {\n return;\n }\n\n const resultObj = result as { content: Array<object> };\n if (!Array.isArray(resultObj.content)) {\n return;\n }\n\n for (const item of resultObj.content) {\n if (isToolError(item)) {\n // Try to get the span associated with this tool call ID\n const associatedSpan = _INTERNAL_getSpanForToolCallId(item.toolCallId) as Span;\n\n if (associatedSpan) {\n // We have the span, so link the error using span and trace IDs from the span\n const spanContext = associatedSpan.spanContext();\n\n withScope(scope => {\n // Set the span and trace context for proper linking\n scope.setContext('trace', {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n });\n\n scope.setTag('vercel.ai.tool.name', item.toolName);\n scope.setTag('vercel.ai.tool.callId', item.toolCallId);\n\n scope.setLevel('error');\n\n captureException(item.error, {\n mechanism: {\n type: 'auto.vercelai.otel',\n handled: false,\n },\n });\n });\n\n // Clean up the span mapping since we've processed this tool error\n // We won't get multiple { type: 'tool-error' } parts for the same toolCallId.\n _INTERNAL_cleanupToolCallSpan(item.toolCallId);\n } else {\n // Fallback: capture without span linking\n withScope(scope => {\n scope.setTag('vercel.ai.tool.name', item.toolName);\n scope.setTag('vercel.ai.tool.callId', item.toolCallId);\n scope.setLevel('error');\n\n captureException(item.error, {\n mechanism: {\n type: 'auto.vercelai.otel',\n handled: false,\n },\n });\n });\n }\n }\n }\n}\n\n/**\n * Determines whether to record inputs and outputs for Vercel AI telemetry based on the configuration hierarchy.\n *\n * The order of precedence is:\n * 1. The vercel ai integration options\n * 2. The experimental_telemetry options in the vercel ai method calls\n * 3. When telemetry is explicitly enabled (isEnabled: true), default to recording\n * 4. Otherwise, use the sendDefaultPii option from client options\n */\nexport function determineRecordingSettings(\n integrationRecordingOptions: RecordingOptions | undefined,\n methodTelemetryOptions: RecordingOptions,\n telemetryExplicitlyEnabled: boolean | undefined,\n defaultRecordingEnabled: boolean,\n): { recordInputs: boolean; recordOutputs: boolean } {\n const recordInputs =\n integrationRecordingOptions?.recordInputs !== undefined\n ? integrationRecordingOptions.recordInputs\n : methodTelemetryOptions.recordInputs !== undefined\n ? methodTelemetryOptions.recordInputs\n : telemetryExplicitlyEnabled === true\n ? true // When telemetry is explicitly enabled, default to recording inputs\n : defaultRecordingEnabled;\n\n const recordOutputs =\n integrationRecordingOptions?.recordOutputs !== undefined\n ? integrationRecordingOptions.recordOutputs\n : methodTelemetryOptions.recordOutputs !== undefined\n ? methodTelemetryOptions.recordOutputs\n : telemetryExplicitlyEnabled === true\n ? true // When telemetry is explicitly enabled, default to recording inputs\n : defaultRecordingEnabled;\n\n return { recordInputs, recordOutputs };\n}\n\n/**\n * This detects is added by the Sentry Vercel AI Integration to detect if the integration should\n * be enabled.\n *\n * It also patches the `ai` module to enable Vercel AI telemetry automatically for all methods.\n */\nexport class SentryVercelAiInstrumentation extends InstrumentationBase {\n private _isPatched = false;\n private _callbacks: (() => void)[] = [];\n\n public constructor(config: InstrumentationConfig = {}) {\n super('@sentry/instrumentation-vercel-ai', 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('ai', SUPPORTED_VERSIONS, this._patch.bind(this));\n return module;\n }\n\n /**\n * Call the provided callback when the module is patched.\n * If it has already been patched, the callback will be called immediately.\n */\n public callWhenPatched(callback: () => void): void {\n if (this._isPatched) {\n callback();\n } else {\n this._callbacks.push(callback);\n }\n }\n\n /**\n * Patches module exports to enable Vercel AI telemetry.\n */\n private _patch(moduleExports: PatchedModuleExports): unknown {\n this._isPatched = true;\n\n this._callbacks.forEach(callback => callback());\n this._callbacks = [];\n\n const generatePatch = <T extends (...args: MethodArgs) => unknown>(originalMethod: T): T => {\n return new Proxy(originalMethod, {\n apply: (target, thisArg, args: MethodArgs) => {\n const existingExperimentalTelemetry = args[0].experimental_telemetry || {};\n const isEnabled = existingExperimentalTelemetry.isEnabled;\n\n const client = getClient();\n const integration = client?.getIntegrationByName<VercelAiIntegration>(INTEGRATION_NAME);\n const integrationOptions = integration?.options;\n const shouldRecordInputsAndOutputs = integration ? Boolean(client?.getOptions().sendDefaultPii) : false;\n\n const { recordInputs, recordOutputs } = determineRecordingSettings(\n integrationOptions,\n existingExperimentalTelemetry,\n isEnabled,\n shouldRecordInputsAndOutputs,\n );\n\n args[0].experimental_telemetry = {\n ...existingExperimentalTelemetry,\n isEnabled: isEnabled !== undefined ? isEnabled : true,\n recordInputs,\n recordOutputs,\n };\n\n return handleCallbackErrors(\n () => Reflect.apply(target, thisArg, args),\n error => {\n // This error bubbles up to unhandledrejection handler (if not handled before),\n // where we do not know the active span anymore\n // So to circumvent this, we set the active span on the error object\n // which is picked up by the unhandledrejection handler\n if (error && typeof error === 'object') {\n addNonEnumerableProperty(error, '_sentry_active_span', getActiveSpan());\n }\n },\n () => {},\n result => {\n checkResultForToolErrors(result);\n },\n );\n },\n });\n };\n\n // Is this an ESM module?\n // https://tc39.es/ecma262/#sec-module-namespace-objects\n if (Object.prototype.toString.call(moduleExports) === '[object Module]') {\n // In ESM we take the usual route and just replace the exports we want to instrument\n for (const method of INSTRUMENTED_METHODS) {\n // Skip methods that don't exist in this version of the AI SDK (e.g., rerank was added in v6)\n if (moduleExports[method] != null) {\n moduleExports[method] = generatePatch(moduleExports[method]);\n }\n }\n\n return moduleExports;\n } else {\n // In CJS we can't replace the exports in the original module because they\n // don't have setters, so we create a new object with the same properties\n const patchedModuleExports = INSTRUMENTED_METHODS.reduce((acc, curr) => {\n // Skip methods that don't exist in this version of the AI SDK (e.g., rerank was added in v6)\n if (moduleExports[curr] != null) {\n acc[curr] = generatePatch(moduleExports[curr]);\n }\n return acc;\n }, {} as PatchedModuleExports);\n\n return { ...moduleExports, ...patchedModuleExports };\n }\n }\n}\n"],"names":["_INTERNAL_getSpanForToolCallId","withScope","captureException","_INTERNAL_cleanupToolCallSpan","InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","getClient","INTEGRATION_NAME","handleCallbackErrors","addNonEnumerableProperty","getActiveSpan"],"mappings":";;;;;;AAiBA,MAAM,kBAAA,GAAqB,CAAC,YAAY,CAAC;;AAEzC;AACA;AACA,MAAM,uBAAuB;AAC7B,EAAE,cAAc;AAChB,EAAE,YAAY;AACd,EAAE,gBAAgB;AAClB,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,WAAW;AACb,EAAE,QAAQ;AACV,CAAA;;AA2BA,SAAS,WAAW,CAAC,GAAG,EAA6B;AACrD,EAAE,IAAI,OAAO,GAAA,KAAQ,YAAY,GAAA,KAAQ,IAAI,EAAE;AAC/C,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,GAAA;AACpB,EAAE;AACF,IAAI,MAAA,IAAU,SAAA;AACd,IAAI,OAAA,IAAW,SAAA;AACf,IAAI,UAAA,IAAc,SAAA;AAClB,IAAI,YAAA,IAAgB,SAAA;AACpB,IAAI,SAAS,CAAC,IAAA,KAAS,YAAA;AACvB,IAAI,SAAS,CAAC,KAAA,YAAiB;AAC/B;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,MAAM,EAAiB;AACzD,EAAE,IAAI,OAAO,MAAA,KAAW,YAAY,MAAA,KAAW,IAAA,IAAQ,EAAE,aAAa,MAAM,CAAC,EAAE;AAC/E,IAAI;AACJ,EAAE;;AAEF,EAAE,MAAM,SAAA,GAAY,MAAA;AACpB,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;AACzC,IAAI;AACJ,EAAE;;AAEF,EAAE,KAAK,MAAM,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AAM,OAAO,aAAa;AAC1B,IAAI,OAAO;AACX;AACA;AACA,MAAM,MAAM,oBAAA,GAAuB,oBAAoB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK;AAC9E;AACA,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAA,IAAK,IAAI,EAAE;AACzC,UAAU,GAAG,CAAC,IAAI,CAAA,GAAI,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACxD,QAAQ;AACR,QAAQ,OAAO,GAAG;AAClB,MAAM,CAAC,EAAE,EAAC,EAA0B;;AAEpC,MAAM,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,sBAAsB;AAC1D,IAAI;AACJ,EAAE;AACF;;;;;"}
@@ -84,6 +84,7 @@ function setupOtel(
84
84
  spanProcessors: [
85
85
  new opentelemetry.SentrySpanProcessor({
86
86
  timeout: _clampSpanProcessorTimeout(client.getOptions().maxSpanWaitDuration),
87
+ client,
87
88
  }),
88
89
  ...(options.spanProcessors || []),
89
90
  ],