@sentry/node 10.56.0 → 10.58.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 (82) hide show
  1. package/build/cjs/integrations/tracing/anthropic-ai/index.js.map +1 -1
  2. package/build/cjs/integrations/tracing/dataloader/index.js +2 -22
  3. package/build/cjs/integrations/tracing/dataloader/index.js.map +1 -1
  4. package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.js +93 -120
  5. package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.js.map +1 -1
  6. package/build/cjs/integrations/tracing/genericPool/index.js +1 -1
  7. package/build/cjs/integrations/tracing/genericPool/index.js.map +1 -1
  8. package/build/cjs/integrations/tracing/genericPool/vendored/instrumentation.js +14 -26
  9. package/build/cjs/integrations/tracing/genericPool/vendored/instrumentation.js.map +1 -1
  10. package/build/cjs/integrations/tracing/google-genai/index.js.map +1 -1
  11. package/build/cjs/integrations/tracing/langchain/index.js.map +1 -1
  12. package/build/cjs/integrations/tracing/langgraph/index.js.map +1 -1
  13. package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js +8 -11
  14. package/build/cjs/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
  15. package/build/cjs/integrations/tracing/openai/index.js.map +1 -1
  16. package/build/cjs/integrations/tracing/postgresjs.js +1 -1
  17. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  18. package/build/cjs/integrations/tracing/redis/index.js +1 -1
  19. package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
  20. package/build/cjs/integrations/tracing/utils/sql-common.js.map +1 -1
  21. package/build/esm/integrations/tracing/anthropic-ai/index.js.map +1 -1
  22. package/build/esm/integrations/tracing/dataloader/index.js +4 -24
  23. package/build/esm/integrations/tracing/dataloader/index.js.map +1 -1
  24. package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.js +95 -122
  25. package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.js.map +1 -1
  26. package/build/esm/integrations/tracing/genericPool/index.js +1 -1
  27. package/build/esm/integrations/tracing/genericPool/index.js.map +1 -1
  28. package/build/esm/integrations/tracing/genericPool/vendored/instrumentation.js +15 -27
  29. package/build/esm/integrations/tracing/genericPool/vendored/instrumentation.js.map +1 -1
  30. package/build/esm/integrations/tracing/google-genai/index.js.map +1 -1
  31. package/build/esm/integrations/tracing/langchain/index.js.map +1 -1
  32. package/build/esm/integrations/tracing/langgraph/index.js.map +1 -1
  33. package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js +8 -11
  34. package/build/esm/integrations/tracing/lrumemoizer/vendored/instrumentation.js.map +1 -1
  35. package/build/esm/integrations/tracing/openai/index.js.map +1 -1
  36. package/build/esm/integrations/tracing/postgresjs.js +1 -1
  37. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  38. package/build/esm/integrations/tracing/redis/index.js +1 -1
  39. package/build/esm/integrations/tracing/redis/index.js.map +1 -1
  40. package/build/esm/integrations/tracing/utils/sql-common.js.map +1 -1
  41. package/build/esm/package.json +1 -1
  42. package/build/types/integrations/tracing/anthropic-ai/index.d.ts +4 -3
  43. package/build/types/integrations/tracing/anthropic-ai/index.d.ts.map +1 -1
  44. package/build/types/integrations/tracing/dataloader/index.d.ts.map +1 -1
  45. package/build/types/integrations/tracing/dataloader/vendored/instrumentation.d.ts +2 -5
  46. package/build/types/integrations/tracing/dataloader/vendored/instrumentation.d.ts.map +1 -1
  47. package/build/types/integrations/tracing/dataloader/vendored/types.d.ts +20 -8
  48. package/build/types/integrations/tracing/dataloader/vendored/types.d.ts.map +1 -1
  49. package/build/types/integrations/tracing/genericPool/index.d.ts.map +1 -1
  50. package/build/types/integrations/tracing/genericPool/vendored/generic-pool-types.d.ts +1 -1
  51. package/build/types/integrations/tracing/genericPool/vendored/generic-pool-types.d.ts.map +1 -1
  52. package/build/types/integrations/tracing/genericPool/vendored/instrumentation.d.ts +2 -1
  53. package/build/types/integrations/tracing/genericPool/vendored/instrumentation.d.ts.map +1 -1
  54. package/build/types/integrations/tracing/google-genai/index.d.ts +8 -7
  55. package/build/types/integrations/tracing/google-genai/index.d.ts.map +1 -1
  56. package/build/types/integrations/tracing/langchain/index.d.ts +9 -8
  57. package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -1
  58. package/build/types/integrations/tracing/langgraph/index.d.ts +4 -3
  59. package/build/types/integrations/tracing/langgraph/index.d.ts.map +1 -1
  60. package/build/types/integrations/tracing/lrumemoizer/vendored/instrumentation.d.ts +2 -2
  61. package/build/types/integrations/tracing/lrumemoizer/vendored/instrumentation.d.ts.map +1 -1
  62. package/build/types/integrations/tracing/openai/index.d.ts +4 -3
  63. package/build/types/integrations/tracing/openai/index.d.ts.map +1 -1
  64. package/build/types/integrations/tracing/postgresjs.d.ts.map +1 -1
  65. package/build/types/integrations/tracing/utils/sql-common.d.ts +1 -1
  66. package/build/types/integrations/tracing/utils/sql-common.d.ts.map +1 -1
  67. package/build/types/integrations/tracing/vercelai/types.d.ts +2 -2
  68. package/build/types-ts3.8/integrations/tracing/anthropic-ai/index.d.ts +4 -3
  69. package/build/types-ts3.8/integrations/tracing/dataloader/vendored/instrumentation.d.ts +2 -5
  70. package/build/types-ts3.8/integrations/tracing/dataloader/vendored/types.d.ts +20 -8
  71. package/build/types-ts3.8/integrations/tracing/genericPool/vendored/generic-pool-types.d.ts +1 -1
  72. package/build/types-ts3.8/integrations/tracing/genericPool/vendored/instrumentation.d.ts +2 -1
  73. package/build/types-ts3.8/integrations/tracing/google-genai/index.d.ts +8 -7
  74. package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +9 -8
  75. package/build/types-ts3.8/integrations/tracing/langgraph/index.d.ts +4 -3
  76. package/build/types-ts3.8/integrations/tracing/lrumemoizer/vendored/instrumentation.d.ts +2 -2
  77. package/build/types-ts3.8/integrations/tracing/openai/index.d.ts +4 -3
  78. package/build/types-ts3.8/integrations/tracing/vercelai/types.d.ts +2 -2
  79. package/package.json +5 -5
  80. package/build/types/integrations/tracing/dataloader/vendored/dataloader-types.d.ts +0 -14
  81. package/build/types/integrations/tracing/dataloader/vendored/dataloader-types.d.ts.map +0 -1
  82. package/build/types-ts3.8/integrations/tracing/dataloader/vendored/dataloader-types.d.ts +0 -14
@@ -1,11 +1,28 @@
1
1
  import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
2
- import { trace, context, SpanStatusCode, SpanKind } from '@opentelemetry/api';
3
- import { SDK_VERSION } from '@sentry/core';
2
+ import { SpanKind } from '@opentelemetry/api';
3
+ import { SDK_VERSION, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
4
4
 
5
5
  const MODULE_NAME = "dataloader";
6
6
  const PACKAGE_NAME = "@sentry/instrumentation-dataloader";
7
+ const ORIGIN = "auto.db.otel.dataloader";
8
+ function isModule(module) {
9
+ return module[Symbol.toStringTag] === "Module";
10
+ }
7
11
  function extractModuleExports(module) {
8
- return module[Symbol.toStringTag] === "Module" ? module.default : module;
12
+ return isModule(module) ? module.default : module;
13
+ }
14
+ function getSpanName(dataloader, operation) {
15
+ const dataloaderName = dataloader.name;
16
+ if (dataloaderName) {
17
+ return `${MODULE_NAME}.${operation} ${dataloaderName}`;
18
+ }
19
+ return `${MODULE_NAME}.${operation}`;
20
+ }
21
+ function getSpanOp(operation) {
22
+ if (operation === "load" || operation === "loadMany" || operation === "batch") {
23
+ return "cache.get";
24
+ }
25
+ return void 0;
9
26
  }
10
27
  class DataloaderInstrumentation extends InstrumentationBase {
11
28
  constructor(config = {}) {
@@ -36,44 +53,24 @@ class DataloaderInstrumentation extends InstrumentationBase {
36
53
  )
37
54
  ];
38
55
  }
39
- shouldCreateSpans() {
40
- const config = this.getConfig();
41
- const hasParentSpan = trace.getSpan(context.active()) !== void 0;
42
- return hasParentSpan || !config.requireParentSpan;
43
- }
44
- getSpanName(dataloader, operation) {
45
- const dataloaderName = dataloader.name;
46
- if (dataloaderName === void 0 || dataloaderName === null) {
47
- return `${MODULE_NAME}.${operation}`;
48
- }
49
- return `${MODULE_NAME}.${operation} ${dataloaderName}`;
50
- }
51
56
  _wrapBatchLoadFn(batchLoadFn) {
52
57
  const instrumentation = this;
53
58
  return function patchedBatchLoadFn(...args) {
54
- if (!instrumentation.isEnabled() || !instrumentation.shouldCreateSpans()) {
59
+ if (!instrumentation.isEnabled()) {
55
60
  return batchLoadFn.call(this, ...args);
56
61
  }
57
- const parent = context.active();
58
- const span = instrumentation.tracer.startSpan(
59
- instrumentation.getSpanName(this, "batch"),
60
- { links: this._batch?.spanLinks },
61
- parent
62
+ return startSpan(
63
+ {
64
+ name: getSpanName(this, "batch"),
65
+ links: this._batch?.spanLinks,
66
+ attributes: {
67
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
68
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("batch")
69
+ },
70
+ onlyIfParent: true
71
+ },
72
+ () => batchLoadFn.apply(this, args)
62
73
  );
63
- return context.with(trace.setSpan(parent, span), () => {
64
- return batchLoadFn.apply(this, args).then((value) => {
65
- span.end();
66
- return value;
67
- }).catch((err) => {
68
- span.recordException(err);
69
- span.setStatus({
70
- code: SpanStatusCode.ERROR,
71
- message: err.message
72
- });
73
- span.end();
74
- throw err;
75
- });
76
- });
77
74
  };
78
75
  }
79
76
  _getPatchedConstructor(constructor) {
@@ -101,39 +98,28 @@ class DataloaderInstrumentation extends InstrumentationBase {
101
98
  this._wrap(proto, "load", this._getPatchedLoad.bind(this));
102
99
  }
103
100
  _getPatchedLoad(original) {
104
- const instrumentation = this;
105
101
  return function patchedLoad(...args) {
106
- if (!instrumentation.shouldCreateSpans()) {
107
- return original.call(this, ...args);
108
- }
109
- const parent = context.active();
110
- const span = instrumentation.tracer.startSpan(
111
- instrumentation.getSpanName(this, "load"),
112
- { kind: SpanKind.CLIENT },
113
- parent
114
- );
115
- return context.with(trace.setSpan(parent, span), () => {
116
- const result = original.call(this, ...args).then((value) => {
117
- span.end();
118
- return value;
119
- }).catch((err) => {
120
- span.recordException(err);
121
- span.setStatus({
122
- code: SpanStatusCode.ERROR,
123
- message: err.message
124
- });
125
- span.end();
126
- throw err;
127
- });
128
- const loader = this;
129
- if (loader._batch) {
130
- if (!loader._batch.spanLinks) {
131
- loader._batch.spanLinks = [];
102
+ return startSpan(
103
+ {
104
+ name: getSpanName(this, "load"),
105
+ kind: SpanKind.CLIENT,
106
+ attributes: {
107
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
108
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("load")
109
+ },
110
+ onlyIfParent: true
111
+ },
112
+ (span) => {
113
+ const result = original.call(this, ...args);
114
+ if (this._batch && span.isRecording()) {
115
+ if (!this._batch.spanLinks) {
116
+ this._batch.spanLinks = [];
117
+ }
118
+ this._batch.spanLinks.push({ context: span.spanContext() });
132
119
  }
133
- loader._batch.spanLinks.push({ context: span.spanContext() });
120
+ return result;
134
121
  }
135
- return result;
136
- });
122
+ );
137
123
  };
138
124
  }
139
125
  _patchLoadMany(proto) {
@@ -143,23 +129,19 @@ class DataloaderInstrumentation extends InstrumentationBase {
143
129
  this._wrap(proto, "loadMany", this._getPatchedLoadMany.bind(this));
144
130
  }
145
131
  _getPatchedLoadMany(original) {
146
- const instrumentation = this;
147
132
  return function patchedLoadMany(...args) {
148
- if (!instrumentation.shouldCreateSpans()) {
149
- return original.call(this, ...args);
150
- }
151
- const parent = context.active();
152
- const span = instrumentation.tracer.startSpan(
153
- instrumentation.getSpanName(this, "loadMany"),
154
- { kind: SpanKind.CLIENT },
155
- parent
133
+ return startSpan(
134
+ {
135
+ name: getSpanName(this, "loadMany"),
136
+ kind: SpanKind.CLIENT,
137
+ attributes: {
138
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
139
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("loadMany")
140
+ },
141
+ onlyIfParent: true
142
+ },
143
+ () => original.call(this, ...args)
156
144
  );
157
- return context.with(trace.setSpan(parent, span), () => {
158
- return original.call(this, ...args).then((value) => {
159
- span.end();
160
- return value;
161
- });
162
- });
163
145
  };
164
146
  }
165
147
  _patchPrime(proto) {
@@ -169,22 +151,19 @@ class DataloaderInstrumentation extends InstrumentationBase {
169
151
  this._wrap(proto, "prime", this._getPatchedPrime.bind(this));
170
152
  }
171
153
  _getPatchedPrime(original) {
172
- const instrumentation = this;
173
154
  return function patchedPrime(...args) {
174
- if (!instrumentation.shouldCreateSpans()) {
175
- return original.call(this, ...args);
176
- }
177
- const parent = context.active();
178
- const span = instrumentation.tracer.startSpan(
179
- instrumentation.getSpanName(this, "prime"),
180
- { kind: SpanKind.CLIENT },
181
- parent
155
+ return startSpan(
156
+ {
157
+ name: getSpanName(this, "prime"),
158
+ kind: SpanKind.CLIENT,
159
+ attributes: {
160
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
161
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("prime")
162
+ },
163
+ onlyIfParent: true
164
+ },
165
+ () => original.call(this, ...args)
182
166
  );
183
- const ret = context.with(trace.setSpan(parent, span), () => {
184
- return original.call(this, ...args);
185
- });
186
- span.end();
187
- return ret;
188
167
  };
189
168
  }
190
169
  _patchClear(proto) {
@@ -194,22 +173,19 @@ class DataloaderInstrumentation extends InstrumentationBase {
194
173
  this._wrap(proto, "clear", this._getPatchedClear.bind(this));
195
174
  }
196
175
  _getPatchedClear(original) {
197
- const instrumentation = this;
198
176
  return function patchedClear(...args) {
199
- if (!instrumentation.shouldCreateSpans()) {
200
- return original.call(this, ...args);
201
- }
202
- const parent = context.active();
203
- const span = instrumentation.tracer.startSpan(
204
- instrumentation.getSpanName(this, "clear"),
205
- { kind: SpanKind.CLIENT },
206
- parent
177
+ return startSpan(
178
+ {
179
+ name: getSpanName(this, "clear"),
180
+ kind: SpanKind.CLIENT,
181
+ attributes: {
182
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
183
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("clear")
184
+ },
185
+ onlyIfParent: true
186
+ },
187
+ () => original.call(this, ...args)
207
188
  );
208
- const ret = context.with(trace.setSpan(parent, span), () => {
209
- return original.call(this, ...args);
210
- });
211
- span.end();
212
- return ret;
213
189
  };
214
190
  }
215
191
  _patchClearAll(proto) {
@@ -219,22 +195,19 @@ class DataloaderInstrumentation extends InstrumentationBase {
219
195
  this._wrap(proto, "clearAll", this._getPatchedClearAll.bind(this));
220
196
  }
221
197
  _getPatchedClearAll(original) {
222
- const instrumentation = this;
223
198
  return function patchedClearAll(...args) {
224
- if (!instrumentation.shouldCreateSpans()) {
225
- return original.call(this, ...args);
226
- }
227
- const parent = context.active();
228
- const span = instrumentation.tracer.startSpan(
229
- instrumentation.getSpanName(this, "clearAll"),
230
- { kind: SpanKind.CLIENT },
231
- parent
199
+ return startSpan(
200
+ {
201
+ name: getSpanName(this, "clearAll"),
202
+ kind: SpanKind.CLIENT,
203
+ attributes: {
204
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
205
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("clearAll")
206
+ },
207
+ onlyIfParent: true
208
+ },
209
+ () => original.call(this, ...args)
232
210
  );
233
- const ret = context.with(trace.setSpan(parent, span), () => {
234
- return original.call(this, ...args);
235
- });
236
- span.end();
237
- return ret;
238
211
  };
239
212
  }
240
213
  }
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/dataloader/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-dataloader\n * - Upstream version: @opentelemetry/instrumentation-dataloader@0.35.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n */\n/* eslint-disable */\n\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { trace, context, Link, SpanStatusCode, SpanKind } from '@opentelemetry/api';\nimport { DataloaderInstrumentationConfig } from './types';\nimport { SDK_VERSION } from '@sentry/core';\nimport type * as Dataloader from './dataloader-types';\n\nconst MODULE_NAME = 'dataloader';\nconst PACKAGE_NAME = '@sentry/instrumentation-dataloader';\n\ntype DataloaderInternal = typeof Dataloader.prototype & {\n _batchLoadFn: Dataloader.BatchLoadFn<unknown, unknown>;\n _batch: { spanLinks?: Link[] } | null;\n};\n\ntype LoadFn = (typeof Dataloader.prototype)['load'];\ntype LoadManyFn = (typeof Dataloader.prototype)['loadMany'];\ntype PrimeFn = (typeof Dataloader.prototype)['prime'];\ntype ClearFn = (typeof Dataloader.prototype)['clear'];\ntype ClearAllFn = (typeof Dataloader.prototype)['clearAll'];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction extractModuleExports(module: any) {\n return module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n}\n\nexport class DataloaderInstrumentation extends InstrumentationBase<DataloaderInstrumentationConfig> {\n constructor(config: DataloaderInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init() {\n return [\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=2.0.0 <3'],\n module => {\n const dataloader = extractModuleExports(module);\n this._patchLoad(dataloader.prototype);\n this._patchLoadMany(dataloader.prototype);\n this._patchPrime(dataloader.prototype);\n this._patchClear(dataloader.prototype);\n this._patchClearAll(dataloader.prototype);\n\n return this._getPatchedConstructor(dataloader);\n },\n module => {\n const dataloader = extractModuleExports(module);\n ['load', 'loadMany', 'prime', 'clear', 'clearAll'].forEach(method => {\n if (isWrapped(dataloader.prototype[method])) {\n this._unwrap(dataloader.prototype, method);\n }\n });\n },\n ),\n ];\n }\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 private getSpanName(\n dataloader: DataloaderInternal,\n operation: 'load' | 'loadMany' | 'batch' | 'prime' | 'clear' | 'clearAll',\n ): string {\n const dataloaderName = dataloader.name;\n if (dataloaderName === undefined || dataloaderName === null) {\n return `${MODULE_NAME}.${operation}`;\n }\n\n return `${MODULE_NAME}.${operation} ${dataloaderName}`;\n }\n\n private _wrapBatchLoadFn(\n batchLoadFn: Dataloader.BatchLoadFn<unknown, unknown>,\n ): Dataloader.BatchLoadFn<unknown, unknown> {\n const instrumentation = this;\n\n return function patchedBatchLoadFn(\n this: DataloaderInternal,\n ...args: Parameters<Dataloader.BatchLoadFn<unknown, unknown>>\n ) {\n if (!instrumentation.isEnabled() || !instrumentation.shouldCreateSpans()) {\n return batchLoadFn.call(this, ...args);\n }\n\n const parent = context.active();\n const span = instrumentation.tracer.startSpan(\n instrumentation.getSpanName(this, 'batch'),\n { links: this._batch?.spanLinks as Link[] | undefined },\n parent,\n );\n\n return context.with(trace.setSpan(parent, span), () => {\n return (batchLoadFn.apply(this, args) as Promise<unknown[]>)\n .then(value => {\n span.end();\n return value;\n })\n .catch((err: Error) => {\n span.recordException(err);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.end();\n throw err;\n });\n });\n };\n }\n\n private _getPatchedConstructor(constructor: typeof Dataloader): typeof Dataloader {\n const instrumentation = this;\n const prototype = constructor.prototype;\n\n if (!instrumentation.isEnabled()) {\n return constructor;\n }\n\n function PatchedDataloader(this: DataloaderInternal, ...args: any[]) {\n // BatchLoadFn is the first constructor argument\n // https://github.com/graphql/dataloader/blob/77c2cd7ca97e8795242018ebc212ce2487e729d2/src/index.js#L47\n if (typeof args[0] === 'function') {\n if (isWrapped(args[0])) {\n instrumentation._unwrap(args, 0);\n }\n\n args[0] = instrumentation._wrapBatchLoadFn(args[0]) as Dataloader.BatchLoadFn<unknown, unknown>;\n }\n\n return (constructor as any).apply(this, args);\n }\n\n PatchedDataloader.prototype = prototype;\n return PatchedDataloader as unknown as typeof Dataloader;\n }\n\n private _patchLoad(proto: typeof Dataloader.prototype) {\n if (isWrapped(proto.load)) {\n this._unwrap(proto, 'load');\n }\n\n this._wrap(proto, 'load', this._getPatchedLoad.bind(this));\n }\n\n private _getPatchedLoad(original: LoadFn): LoadFn {\n const instrumentation = this;\n\n return function patchedLoad(this: DataloaderInternal, ...args: Parameters<typeof original>) {\n if (!instrumentation.shouldCreateSpans()) {\n return original.call(this, ...args);\n }\n\n const parent = context.active();\n const span = instrumentation.tracer.startSpan(\n instrumentation.getSpanName(this, 'load'),\n { kind: SpanKind.CLIENT },\n parent,\n );\n\n return context.with(trace.setSpan(parent, span), () => {\n const result = original\n .call(this, ...args)\n .then((value: unknown) => {\n span.end();\n return value;\n })\n .catch((err: Error) => {\n span.recordException(err);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.end();\n throw err;\n });\n\n const loader = this as DataloaderInternal;\n\n if (loader._batch) {\n if (!loader._batch.spanLinks) {\n loader._batch.spanLinks = [];\n }\n\n loader._batch.spanLinks.push({ context: span.spanContext() } as Link);\n }\n\n return result;\n });\n };\n }\n\n private _patchLoadMany(proto: typeof Dataloader.prototype) {\n if (isWrapped(proto.loadMany)) {\n this._unwrap(proto, 'loadMany');\n }\n\n this._wrap(proto, 'loadMany', this._getPatchedLoadMany.bind(this));\n }\n\n private _getPatchedLoadMany(original: LoadManyFn): LoadManyFn {\n const instrumentation = this;\n\n return function patchedLoadMany(this: DataloaderInternal, ...args: Parameters<typeof original>) {\n if (!instrumentation.shouldCreateSpans()) {\n return original.call(this, ...args);\n }\n\n const parent = context.active();\n const span = instrumentation.tracer.startSpan(\n instrumentation.getSpanName(this, 'loadMany'),\n { kind: SpanKind.CLIENT },\n parent,\n );\n\n return context.with(trace.setSpan(parent, span), () => {\n // .loadMany never rejects, as errors from internal .load\n // calls are caught by dataloader lib\n return original.call(this, ...args).then((value: unknown) => {\n span.end();\n return value;\n });\n });\n };\n }\n\n private _patchPrime(proto: typeof Dataloader.prototype) {\n if (isWrapped(proto.prime)) {\n this._unwrap(proto, 'prime');\n }\n\n this._wrap(proto, 'prime', this._getPatchedPrime.bind(this));\n }\n\n private _getPatchedPrime(original: PrimeFn): PrimeFn {\n const instrumentation = this;\n\n return function patchedPrime(this: DataloaderInternal, ...args: Parameters<typeof original>) {\n if (!instrumentation.shouldCreateSpans()) {\n return original.call(this, ...args);\n }\n\n const parent = context.active();\n const span = instrumentation.tracer.startSpan(\n instrumentation.getSpanName(this, 'prime'),\n { kind: SpanKind.CLIENT },\n parent,\n );\n\n const ret = context.with(trace.setSpan(parent, span), () => {\n return original.call(this, ...args);\n });\n\n span.end();\n\n return ret;\n };\n }\n\n private _patchClear(proto: typeof Dataloader.prototype) {\n if (isWrapped(proto.clear)) {\n this._unwrap(proto, 'clear');\n }\n\n this._wrap(proto, 'clear', this._getPatchedClear.bind(this));\n }\n\n private _getPatchedClear(original: ClearFn): ClearFn {\n const instrumentation = this;\n\n return function patchedClear(this: DataloaderInternal, ...args: Parameters<typeof original>) {\n if (!instrumentation.shouldCreateSpans()) {\n return original.call(this, ...args);\n }\n\n const parent = context.active();\n const span = instrumentation.tracer.startSpan(\n instrumentation.getSpanName(this, 'clear'),\n { kind: SpanKind.CLIENT },\n parent,\n );\n\n const ret = context.with(trace.setSpan(parent, span), () => {\n return original.call(this, ...args);\n });\n\n span.end();\n\n return ret;\n };\n }\n\n private _patchClearAll(proto: typeof Dataloader.prototype) {\n if (isWrapped(proto.clearAll)) {\n this._unwrap(proto, 'clearAll');\n }\n\n this._wrap(proto, 'clearAll', this._getPatchedClearAll.bind(this));\n }\n\n private _getPatchedClearAll(original: ClearAllFn): ClearAllFn {\n const instrumentation = this;\n\n return function patchedClearAll(this: DataloaderInternal, ...args: Parameters<typeof original>) {\n if (!instrumentation.shouldCreateSpans()) {\n return original.call(this, ...args);\n }\n\n const parent = context.active();\n const span = instrumentation.tracer.startSpan(\n instrumentation.getSpanName(this, 'clearAll'),\n { kind: SpanKind.CLIENT },\n parent,\n );\n\n const ret = context.with(trace.setSpan(parent, span), () => {\n return original.call(this, ...args);\n });\n\n span.end();\n\n return ret;\n };\n }\n}\n"],"names":[],"mappings":";;;;AA4BA,MAAM,WAAA,GAAc,YAAA;AACpB,MAAM,YAAA,GAAe,oCAAA;AAcrB,SAAS,qBAAqB,MAAA,EAAa;AACzC,EAAA,OAAO,OAAO,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA,GAClC,OAAO,OAAA,GACP,MAAA;AACN;AAEO,MAAM,kCAAkC,mBAAA,CAAqD;AAAA,EAClG,WAAA,CAAY,MAAA,GAA0C,EAAC,EAAG;AACxD,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAAO;AACf,IAAA,OAAO;AAAA,MACL,IAAI,mCAAA;AAAA,QACF,WAAA;AAAA,QACA,CAAC,YAAY,CAAA;AAAA,QACb,CAAA,MAAA,KAAU;AACR,UAAA,MAAM,UAAA,GAAa,qBAAqB,MAAM,CAAA;AAC9C,UAAA,IAAA,CAAK,UAAA,CAAW,WAAW,SAAS,CAAA;AACpC,UAAA,IAAA,CAAK,cAAA,CAAe,WAAW,SAAS,CAAA;AACxC,UAAA,IAAA,CAAK,WAAA,CAAY,WAAW,SAAS,CAAA;AACrC,UAAA,IA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AAAA,QAClC,eAAA,CAAgB,WAAA,CAAY,IAAA,EAAM,UAAU,CAAA;AAAA,QAC5C,EAAE,IAAA,EAAM,QAAA,CAAS,MAAA,EAAO;AAAA,QACxB;AAAA,OACF;AAEA,MAAA,MAAM,GAAA,GAAM,QAAQ,IAAA,CAAK,KAAA,CAAM,QAAQ,MAAA,EAAQ,IAAI,GAAG,MAAM;AAC1D,QAAA,OAAO,QAAA,CAAS,IAAA,CAAK,IAAA,EAAM,GAAG,IAAI,CAAA;AAAA,MACpC,CAAC,CAAA;AAED,MAAA,IAAA,CAAK,GAAA,EAAI;AAET,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/dataloader/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-dataloader\n * - Upstream version: @opentelemetry/instrumentation-dataloader@0.35.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n */\n\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { SpanKind } from '@opentelemetry/api';\nimport type { BatchLoadFn, DataLoader, DataLoaderConstructor } from './types';\nimport { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core';\n\nconst MODULE_NAME = 'dataloader';\nconst PACKAGE_NAME = '@sentry/instrumentation-dataloader';\nconst ORIGIN = 'auto.db.otel.dataloader';\n\ntype LoadFn = DataLoader['load'];\ntype LoadManyFn = DataLoader['loadMany'];\ntype PrimeFn = DataLoader['prime'];\ntype ClearFn = DataLoader['clear'];\ntype ClearAllFn = DataLoader['clearAll'];\n\nfunction isModule(module: unknown): module is { [Symbol.toStringTag]: 'Module'; default: DataLoaderConstructor } {\n return (module as { [Symbol.toStringTag]: string })[Symbol.toStringTag] === 'Module';\n}\n\nfunction extractModuleExports(module: unknown): DataLoaderConstructor {\n return isModule(module)\n ? module.default // ESM\n : (module as DataLoaderConstructor); // CommonJS\n}\n\nfunction getSpanName(\n dataloader: DataLoader,\n operation: 'load' | 'loadMany' | 'batch' | 'prime' | 'clear' | 'clearAll',\n): string {\n const dataloaderName = dataloader.name;\n if (dataloaderName) {\n return `${MODULE_NAME}.${operation} ${dataloaderName}`;\n }\n\n return `${MODULE_NAME}.${operation}`;\n}\n\n// `load`, `loadMany` and `batch` are all cache reads\nfunction getSpanOp(operation: 'load' | 'loadMany' | 'batch' | 'prime' | 'clear' | 'clearAll'): string | undefined {\n if (operation === 'load' || operation === 'loadMany' || operation === 'batch') {\n return 'cache.get';\n }\n\n return undefined;\n}\n\nexport class DataloaderInstrumentation extends InstrumentationBase {\n constructor(config = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init() {\n return [\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=2.0.0 <3'],\n module => {\n const dataloader = extractModuleExports(module);\n this._patchLoad(dataloader.prototype);\n this._patchLoadMany(dataloader.prototype);\n this._patchPrime(dataloader.prototype);\n this._patchClear(dataloader.prototype);\n this._patchClearAll(dataloader.prototype);\n\n return this._getPatchedConstructor(dataloader);\n },\n module => {\n const dataloader = extractModuleExports(module);\n ['load', 'loadMany', 'prime', 'clear', 'clearAll'].forEach(method => {\n if (isWrapped(dataloader.prototype[method])) {\n this._unwrap(dataloader.prototype, method);\n }\n });\n },\n ),\n ];\n }\n\n private _wrapBatchLoadFn(batchLoadFn: BatchLoadFn<unknown, unknown>): BatchLoadFn<unknown, unknown> {\n // oxlint-disable-next-line typescript/no-this-alias\n const instrumentation = this;\n\n return function patchedBatchLoadFn(this: DataLoader, ...args: Parameters<BatchLoadFn<unknown, unknown>>) {\n if (!instrumentation.isEnabled()) {\n return batchLoadFn.call(this, ...args);\n }\n\n return startSpan(\n {\n name: getSpanName(this, 'batch'),\n links: this._batch?.spanLinks,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp('batch'),\n },\n onlyIfParent: true,\n },\n () => batchLoadFn.apply(this, args),\n );\n };\n }\n\n private _getPatchedConstructor(constructor: DataLoaderConstructor): DataLoaderConstructor {\n // oxlint-disable-next-line typescript/no-this-alias\n const instrumentation = this;\n const prototype = constructor.prototype;\n\n if (!instrumentation.isEnabled()) {\n return constructor;\n }\n\n // oxlint-disable-next-line typescript/no-explicit-any\n function PatchedDataloader(this: DataLoader, ...args: any[]) {\n // BatchLoadFn is the first constructor argument\n // https://github.com/graphql/dataloader/blob/77c2cd7ca97e8795242018ebc212ce2487e729d2/src/index.js#L47\n if (typeof args[0] === 'function') {\n if (isWrapped(args[0])) {\n instrumentation._unwrap(args, 0);\n }\n\n args[0] = instrumentation._wrapBatchLoadFn(args[0]);\n }\n\n return constructor.apply(this, args);\n }\n\n PatchedDataloader.prototype = prototype;\n return PatchedDataloader as unknown as DataLoaderConstructor;\n }\n\n private _patchLoad(proto: DataLoader) {\n // oxlint-disable-next-line typescript/unbound-method\n if (isWrapped(proto.load)) {\n this._unwrap(proto, 'load');\n }\n\n this._wrap(proto, 'load', this._getPatchedLoad.bind(this));\n }\n\n private _getPatchedLoad(original: LoadFn): LoadFn {\n return function patchedLoad(this: DataLoader, ...args: Parameters<typeof original>) {\n return startSpan(\n {\n name: getSpanName(this, 'load'),\n kind: SpanKind.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp('load'),\n },\n onlyIfParent: true,\n },\n span => {\n const result = original.call(this, ...args);\n\n if (this._batch && span.isRecording()) {\n if (!this._batch.spanLinks) {\n this._batch.spanLinks = [];\n }\n\n this._batch.spanLinks.push({ context: span.spanContext() });\n }\n\n return result;\n },\n );\n };\n }\n\n private _patchLoadMany(proto: DataLoader) {\n // oxlint-disable-next-line typescript/unbound-method\n if (isWrapped(proto.loadMany)) {\n this._unwrap(proto, 'loadMany');\n }\n\n this._wrap(proto, 'loadMany', this._getPatchedLoadMany.bind(this));\n }\n\n private _getPatchedLoadMany(original: LoadManyFn): LoadManyFn {\n return function patchedLoadMany(this: DataLoader, ...args: Parameters<typeof original>) {\n return startSpan(\n {\n name: getSpanName(this, 'loadMany'),\n kind: SpanKind.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp('loadMany'),\n },\n onlyIfParent: true,\n },\n () => original.call(this, ...args),\n );\n };\n }\n\n private _patchPrime(proto: DataLoader) {\n // oxlint-disable-next-line typescript/unbound-method\n if (isWrapped(proto.prime)) {\n this._unwrap(proto, 'prime');\n }\n\n this._wrap(proto, 'prime', this._getPatchedPrime.bind(this));\n }\n\n private _getPatchedPrime(original: PrimeFn): PrimeFn {\n return function patchedPrime(this: DataLoader, ...args: Parameters<typeof original>) {\n return startSpan(\n {\n name: getSpanName(this, 'prime'),\n kind: SpanKind.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp('prime'),\n },\n onlyIfParent: true,\n },\n () => original.call(this, ...args),\n );\n };\n }\n\n private _patchClear(proto: DataLoader) {\n // oxlint-disable-next-line typescript/unbound-method\n if (isWrapped(proto.clear)) {\n this._unwrap(proto, 'clear');\n }\n\n this._wrap(proto, 'clear', this._getPatchedClear.bind(this));\n }\n\n private _getPatchedClear(original: ClearFn): ClearFn {\n return function patchedClear(this: DataLoader, ...args: Parameters<typeof original>) {\n return startSpan(\n {\n name: getSpanName(this, 'clear'),\n kind: SpanKind.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp('clear'),\n },\n onlyIfParent: true,\n },\n () => original.call(this, ...args),\n );\n };\n }\n\n private _patchClearAll(proto: DataLoader) {\n // oxlint-disable-next-line typescript/unbound-method\n if (isWrapped(proto.clearAll)) {\n this._unwrap(proto, 'clearAll');\n }\n\n this._wrap(proto, 'clearAll', this._getPatchedClearAll.bind(this));\n }\n\n private _getPatchedClearAll(original: ClearAllFn): ClearAllFn {\n return function patchedClearAll(this: DataLoader, ...args: Parameters<typeof original>) {\n return startSpan(\n {\n name: getSpanName(this, 'clearAll'),\n kind: SpanKind.CLIENT,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp('clearAll'),\n },\n onlyIfParent: true,\n },\n () => original.call(this, ...args),\n );\n };\n }\n}\n"],"names":[],"mappings":";;;;AA0BA,MAAM,WAAA,GAAc,YAAA;AACpB,MAAM,YAAA,GAAe,oCAAA;AACrB,MAAM,MAAA,GAAS,yBAAA;AAQf,SAAS,SAAS,MAAA,EAA+F;AAC/G,EAAA,OAAQ,MAAA,CAA4C,MAAA,CAAO,WAAW,CAAA,KAAM,QAAA;AAC9E;AAEA,SAAS,qBAAqB,MAAA,EAAwC;AACpE,EAAA,OAAO,QAAA,CAAS,MAAM,CAAA,GAClB,MAAA,CAAO,OAAA,GACN,MAAA;AACP;AAEA,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AA,CAAU,OAAO;AAAA,WACnD;AAAA,UACA,YAAA,EAAc;AAAA,SAChB;AAAA,QACA,MAAM,QAAA,CAAS,IAAA,CAAK,IAAA,EAAM,GAAG,IAAI;AAAA,OACnC;AAAA,IACF,CAAA;AAAA,EACF;AAAA,EAEQ,eAAe,KAAA,EAAmB;AAExC,IAAA,IAAI,SAAA,CAAU,KAAA,CAAM,QAAQ,CAAA,EAAG;AAC7B,MAAA,IAAA,CAAK,OAAA,CAAQ,OAAO,UAAU,CAAA;AAAA,IAChC;AAEA,IAAA,IAAA,CAAK,MAAM,KAAA,EAAO,UAAA,EAAY,KAAK,mBAAA,CAAoB,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,EACnE;AAAA,EAEQ,oBAAoB,QAAA,EAAkC;AAC5D,IAAA,OAAO,SAAS,mBAAqC,IAAA,EAAmC;AACtF,MAAA,OAAO,SAAA;AAAA,QACL;AAAA,UACE,IAAA,EAAM,WAAA,CAAY,IAAA,EAAM,UAAU,CAAA;AAAA,UAClC,MAAM,QAAA,CAAS,MAAA;AAAA,UACf,UAAA,EAAY;AAAA,YACV,CAAC,gCAAgC,GAAG,MAAA;AAAA,YACpC,CAAC,4BAA4B,GAAG,SAAA,CAAU,UAAU;AAAA,WACtD;AAAA,UACA,YAAA,EAAc;AAAA,SAChB;AAAA,QACA,MAAM,QAAA,CAAS,IAAA,CAAK,IAAA,EAAM,GAAG,IAAI;AAAA,OACnC;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"}
@@ -17,7 +17,7 @@ const _genericPoolIntegration = (() => {
17
17
  () => client.on("spanStart", (span) => {
18
18
  const spanJSON = spanToJSON(span);
19
19
  const spanDescription = spanJSON.description;
20
- const isGenericPoolSpan = spanDescription === "generic-pool.aquire" || spanDescription === "generic-pool.acquire";
20
+ const isGenericPoolSpan = spanDescription === "generic-pool.acquire";
21
21
  if (isGenericPoolSpan) {
22
22
  span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, "auto.db.otel.generic_pool");
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/genericPool/index.ts"],"sourcesContent":["import { GenericPoolInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce, instrumentWhenWrapped } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'GenericPool';\n\nexport const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));\n\nconst _genericPoolIntegration = (() => {\n let instrumentationWrappedCallback: undefined | ((callback: () => void) => void);\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentation = instrumentGenericPool();\n instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);\n },\n\n setup(client) {\n instrumentationWrappedCallback?.(() =>\n client.on('spanStart', span => {\n const spanJSON = spanToJSON(span);\n\n const spanDescription = spanJSON.description;\n\n // typo in emitted span for version <= 0.38.0 of @opentelemetry/instrumentation-generic-pool\n const isGenericPoolSpan =\n spanDescription === 'generic-pool.aquire' || spanDescription === 'generic-pool.acquire';\n\n if (isGenericPoolSpan) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.generic_pool');\n }\n }),\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.\n *\n * For more information, see the [`genericPoolIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.genericPoolIntegration()],\n * });\n * ```\n */\nexport const genericPoolIntegration = defineIntegration(_genericPoolIntegration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,aAAA;AAElB,MAAM,qBAAA,GAAwB,uBAAuB,gBAAA,EAAkB,MAAM,IAAI,0BAAA,CAA2B,EAAE,CAAC;AAEtH,MAAM,2BAA2B,MAAM;AACrC,EAAA,IAAI,8BAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,MAAM,kBAAkB,qBAAA,EAAsB;AAC9C,MAAA,8BAAA,GAAiC,sBAAsB,eAAe,CAAA;AAAA,IACxE,CAAA;AAAA,IAEA,MAAM,MAAA,EAAQ;AACZ,MAAA,8BAAA;AAAA,QAAiC,MAC/B,MAAA,CAAO,EAAA,CAAG,WAAA,EAAa,CAAA,IAAA,KAAQ;AAC7B,UAAA,MAAM,QAAA,GAAW,WAAW,IAAI,CAAA;AAEhC,UAAA,MAAM,kBAAkB,QAAA,CAAS,WAAA;AAGjC,UAAA,MAAM,iBAAA,GACJ,eAAA,KAAoB,qBAAA,IAAyB,eAAA,KAAoB,sBAAA;AAEnE,UAAA,IAAI,iBAAA,EAAmB;AACrB,YAAA,IAAA,CAAK,YAAA,CAAa,kCAAkC,2BAA2B,CAAA;AAAA,UACjF;AAAA,QACF,CAAC;AAAA,OACH;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/genericPool/index.ts"],"sourcesContent":["import { GenericPoolInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce, instrumentWhenWrapped } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'GenericPool';\n\nexport const instrumentGenericPool = generateInstrumentOnce(INTEGRATION_NAME, () => new GenericPoolInstrumentation({}));\n\nconst _genericPoolIntegration = (() => {\n let instrumentationWrappedCallback: undefined | ((callback: () => void) => void);\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentation = instrumentGenericPool();\n instrumentationWrappedCallback = instrumentWhenWrapped(instrumentation);\n },\n\n setup(client) {\n instrumentationWrappedCallback?.(() =>\n client.on('spanStart', span => {\n const spanJSON = spanToJSON(span);\n const spanDescription = spanJSON.description;\n const isGenericPoolSpan = spanDescription === 'generic-pool.acquire';\n\n if (isGenericPoolSpan) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.generic_pool');\n }\n }),\n );\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [generic-pool](https://www.npmjs.com/package/generic-pool) library.\n *\n * For more information, see the [`genericPoolIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/genericpool/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.genericPoolIntegration()],\n * });\n * ```\n */\nexport const genericPoolIntegration = defineIntegration(_genericPoolIntegration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,aAAA;AAElB,MAAM,qBAAA,GAAwB,uBAAuB,gBAAA,EAAkB,MAAM,IAAI,0BAAA,CAA2B,EAAE,CAAC;AAEtH,MAAM,2BAA2B,MAAM;AACrC,EAAA,IAAI,8BAAA;AAEJ,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,MAAM,kBAAkB,qBAAA,EAAsB;AAC9C,MAAA,8BAAA,GAAiC,sBAAsB,eAAe,CAAA;AAAA,IACxE,CAAA;AAAA,IAEA,MAAM,MAAA,EAAQ;AACZ,MAAA,8BAAA;AAAA,QAAiC,MAC/B,MAAA,CAAO,EAAA,CAAG,WAAA,EAAa,CAAA,IAAA,KAAQ;AAC7B,UAAA,MAAM,QAAA,GAAW,WAAW,IAAI,CAAA;AAChC,UAAA,MAAM,kBAAkB,QAAA,CAAS,WAAA;AACjC,UAAA,MAAM,oBAAoB,eAAA,KAAoB,sBAAA;AAE9C,UAAA,IAAI,iBAAA,EAAmB;AACrB,YAAA,IAAA,CAAK,YAAA,CAAa,kCAAkC,2BAA2B,CAAA;AAAA,UACjF;AAAA,QACF,CAAC;AAAA,OACH;AAAA,IACF;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
@@ -1,6 +1,5 @@
1
- import * as api from '@opentelemetry/api';
2
1
  import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
3
- import { SDK_VERSION } from '@sentry/core';
2
+ import { SDK_VERSION, startSpan, startSpanManual, SPAN_STATUS_ERROR } from '@sentry/core';
4
3
 
5
4
  const MODULE_NAME = "generic-pool";
6
5
  const PACKAGE_NAME = "@sentry/instrumentation-generic-pool";
@@ -65,48 +64,37 @@ class GenericPoolInstrumentation extends InstrumentationBase {
65
64
  ];
66
65
  }
67
66
  _acquirePatcher(original) {
68
- const instrumentation = this;
69
67
  return function wrapped_acquire(...args) {
70
- const parent = api.context.active();
71
- const span = instrumentation.tracer.startSpan("generic-pool.acquire", {}, parent);
72
- return api.context.with(api.trace.setSpan(parent, span), () => {
73
- return original.call(this, ...args).then(
74
- (value) => {
75
- span.end();
76
- return value;
77
- },
78
- (err) => {
79
- span.recordException(err);
80
- span.end();
81
- throw err;
82
- }
83
- );
68
+ return startSpan({ name: "generic-pool.acquire" }, () => {
69
+ return original.call(this, ...args);
84
70
  });
85
71
  };
86
72
  }
87
73
  _poolWrapper(original) {
88
- const instrumentation = this;
89
- return function wrapped_pool() {
90
- const pool = original.apply(this, arguments);
91
- instrumentation._wrap(pool, "acquire", instrumentation._acquireWithCallbacksPatcher.bind(instrumentation));
74
+ const wrap = this._wrap.bind(this);
75
+ const acquireWithCallbacksPatcher = this._acquireWithCallbacksPatcher.bind(this);
76
+ return function wrapped_pool(...args) {
77
+ const pool = original.apply(this, args);
78
+ wrap(pool, "acquire", acquireWithCallbacksPatcher);
92
79
  return pool;
93
80
  };
94
81
  }
95
82
  _acquireWithCallbacksPatcher(original) {
96
- const instrumentation = this;
83
+ const isDisabled = () => this._isDisabled;
97
84
  return function wrapped_acquire(cb, priority) {
98
- if (instrumentation._isDisabled) {
85
+ if (isDisabled()) {
99
86
  return original.call(this, cb, priority);
100
87
  }
101
- const parent = api.context.active();
102
- const span = instrumentation.tracer.startSpan("generic-pool.acquire", {}, parent);
103
- return api.context.with(api.trace.setSpan(parent, span), () => {
88
+ return startSpanManual({ name: "generic-pool.acquire" }, (span) => {
104
89
  original.call(
105
90
  this,
106
91
  (err, client) => {
92
+ if (err) {
93
+ span.setStatus({ code: SPAN_STATUS_ERROR, message: "internal_error" });
94
+ }
107
95
  span.end();
108
96
  if (cb) {
109
- return cb(err, client);
97
+ cb(err, client);
110
98
  }
111
99
  },
112
100
  priority
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/genericPool/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-generic-pool\n * - Upstream version: @opentelemetry/instrumentation-generic-pool@0.61.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n */\n/* eslint-disable */\n\nimport * as api from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationConfig,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n} from '@opentelemetry/instrumentation';\n\nimport type * as genericPool from './generic-pool-types';\n\nimport { SDK_VERSION } from '@sentry/core';\n\nconst MODULE_NAME = 'generic-pool';\nconst PACKAGE_NAME = '@sentry/instrumentation-generic-pool';\n\nexport class GenericPoolInstrumentation extends InstrumentationBase {\n // only used for v2 - v2.3)\n private _isDisabled = false;\n\n constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=3.0.0 <4'],\n moduleExports => {\n const Pool: any = moduleExports.Pool;\n if (isWrapped(Pool.prototype.acquire)) {\n this._unwrap(Pool.prototype, 'acquire');\n }\n this._wrap(Pool.prototype, 'acquire', this._acquirePatcher.bind(this));\n return moduleExports;\n },\n moduleExports => {\n const Pool: any = moduleExports.Pool;\n this._unwrap(Pool.prototype, 'acquire');\n return moduleExports;\n },\n ),\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=2.4.0 <3'],\n moduleExports => {\n const Pool: any = moduleExports.Pool;\n if (isWrapped(Pool.prototype.acquire)) {\n this._unwrap(Pool.prototype, 'acquire');\n }\n this._wrap(Pool.prototype, 'acquire', this._acquireWithCallbacksPatcher.bind(this));\n return moduleExports;\n },\n moduleExports => {\n const Pool: any = moduleExports.Pool;\n this._unwrap(Pool.prototype, 'acquire');\n return moduleExports;\n },\n ),\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=2.0.0 <2.4'],\n moduleExports => {\n this._isDisabled = false;\n if (isWrapped(moduleExports.Pool)) {\n this._unwrap(moduleExports, 'Pool');\n }\n this._wrap(moduleExports, 'Pool', this._poolWrapper.bind(this));\n return moduleExports;\n },\n moduleExports => {\n // since the object is created on the fly every time, we need to use\n // a boolean switch here to disable the instrumentation\n this._isDisabled = true;\n return moduleExports;\n },\n ),\n ];\n }\n\n private _acquirePatcher(original: genericPool.Pool<unknown>['acquire']) {\n const instrumentation = this;\n return function wrapped_acquire(this: genericPool.Pool<unknown>, ...args: any[]) {\n const parent = api.context.active();\n const span = instrumentation.tracer.startSpan('generic-pool.acquire', {}, parent);\n\n return api.context.with(api.trace.setSpan(parent, span), () => {\n return original.call(this, ...args).then(\n (value: unknown) => {\n span.end();\n return value;\n },\n (err: unknown) => {\n span.recordException(err as Error);\n span.end();\n throw err;\n },\n );\n });\n };\n }\n\n private _poolWrapper(original: any) {\n const instrumentation = this;\n return function wrapped_pool(this: any) {\n const pool = original.apply(this, arguments);\n instrumentation._wrap(pool, 'acquire', instrumentation._acquireWithCallbacksPatcher.bind(instrumentation));\n return pool;\n };\n }\n\n private _acquireWithCallbacksPatcher(original: any) {\n const instrumentation = this;\n return function wrapped_acquire(this: genericPool.Pool<unknown>, cb: Function, priority: number) {\n // only used for v2 - v2.3\n if (instrumentation._isDisabled) {\n return original.call(this, cb, priority);\n }\n const parent = api.context.active();\n const span = instrumentation.tracer.startSpan('generic-pool.acquire', {}, parent);\n\n return api.context.with(api.trace.setSpan(parent, span), () => {\n original.call(\n this,\n (err: unknown, client: unknown) => {\n span.end();\n // Not checking whether cb is a function because\n // the original code doesn't do that either.\n if (cb) {\n return cb(err, client);\n }\n },\n priority,\n );\n });\n };\n }\n}\n"],"names":[],"mappings":";;;;AAkCA,MAAM,WAAA,GAAc,cAAA;AACpB,MAAM,YAAA,GAAe,sCAAA;AAEd,MAAM,mCAAmC,mBAAA,CAAoB;AAAA,EAIlE,WAAA,CAAY,MAAA,GAAgC,EAAC,EAAG;AAC9C,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAHzC;AAAA,IAAA,IAAA,CAAQ,WAAA,GAAc,KAAA;AAAA,EAItB;AAAA,EAEA,IAAA,GAAO;AACL,IAAA,OAAO;AAAA,MACL,IAAI,mCAAA;AAAA,QACF,WAAA;AAAA,QACA,CAAC,YAAY,CAAA;AAAA,QACb,CAA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AAAA,IACH,CAAA;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/genericPool/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-generic-pool\n * - Upstream version: @opentelemetry/instrumentation-generic-pool@0.61.0\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n */\n\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { SDK_VERSION, SPAN_STATUS_ERROR, startSpan, startSpanManual } from '@sentry/core';\nimport type * as genericPool from './generic-pool-types';\n\nconst MODULE_NAME = 'generic-pool';\nconst PACKAGE_NAME = '@sentry/instrumentation-generic-pool';\n\ntype AcquireFn = (this: unknown, ...args: unknown[]) => unknown;\ninterface PoolConstructor {\n prototype: { acquire: AcquireFn };\n}\ninterface GenericPoolModule {\n Pool: PoolConstructor;\n}\n\nexport class GenericPoolInstrumentation extends InstrumentationBase {\n // only used for v2 - v2.3)\n private _isDisabled = false;\n\n constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=3.0.0 <4'],\n (moduleExports: GenericPoolModule) => {\n const Pool = moduleExports.Pool;\n if (isWrapped(Pool.prototype.acquire)) {\n this._unwrap(Pool.prototype, 'acquire');\n }\n this._wrap(Pool.prototype, 'acquire', this._acquirePatcher.bind(this));\n return moduleExports;\n },\n (moduleExports: GenericPoolModule) => {\n const Pool = moduleExports.Pool;\n this._unwrap(Pool.prototype, 'acquire');\n return moduleExports;\n },\n ),\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=2.4.0 <3'],\n (moduleExports: GenericPoolModule) => {\n const Pool = moduleExports.Pool;\n if (isWrapped(Pool.prototype.acquire)) {\n this._unwrap(Pool.prototype, 'acquire');\n }\n this._wrap(Pool.prototype, 'acquire', this._acquireWithCallbacksPatcher.bind(this));\n return moduleExports;\n },\n (moduleExports: GenericPoolModule) => {\n const Pool = moduleExports.Pool;\n this._unwrap(Pool.prototype, 'acquire');\n return moduleExports;\n },\n ),\n new InstrumentationNodeModuleDefinition(\n MODULE_NAME,\n ['>=2.0.0 <2.4'],\n (moduleExports: GenericPoolModule) => {\n this._isDisabled = false;\n if (isWrapped(moduleExports.Pool)) {\n this._unwrap(moduleExports, 'Pool');\n }\n this._wrap(moduleExports, 'Pool', this._poolWrapper.bind(this));\n return moduleExports;\n },\n (moduleExports: GenericPoolModule) => {\n // since the object is created on the fly every time, we need to use\n // a boolean switch here to disable the instrumentation\n this._isDisabled = true;\n return moduleExports;\n },\n ),\n ];\n }\n\n private _acquirePatcher(original: AcquireFn) {\n return function wrapped_acquire(this: genericPool.Pool<unknown>, ...args: unknown[]) {\n return startSpan({ name: 'generic-pool.acquire' }, () => {\n return original.call(this, ...args) as PromiseLike<unknown>;\n });\n };\n }\n\n private _poolWrapper(original: (this: unknown, ...args: unknown[]) => { acquire: AcquireFn }) {\n const wrap = this._wrap.bind(this);\n const acquireWithCallbacksPatcher = this._acquireWithCallbacksPatcher.bind(this);\n return function wrapped_pool(this: unknown, ...args: unknown[]) {\n const pool = original.apply(this, args);\n wrap(pool, 'acquire', acquireWithCallbacksPatcher);\n return pool;\n };\n }\n\n private _acquireWithCallbacksPatcher(original: AcquireFn) {\n const isDisabled = (): boolean => this._isDisabled;\n return function wrapped_acquire(\n this: genericPool.Pool<unknown>,\n cb: (err: unknown, client: unknown) => unknown,\n priority: number,\n ) {\n // only used for v2 - v2.3\n if (isDisabled()) {\n return original.call(this, cb, priority);\n }\n\n return startSpanManual({ name: 'generic-pool.acquire' }, span => {\n original.call(\n this,\n (err: unknown, client: unknown) => {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });\n }\n span.end();\n // Not checking whether cb is a function because\n // the original code doesn't do that either.\n // The callback's return value is unused by generic-pool, so we don't return it.\n if (cb) {\n cb(err, client);\n }\n },\n priority,\n );\n });\n };\n }\n}\n"],"names":[],"mappings":";;;AA0BA,MAAM,WAAA,GAAc,cAAA;AACpB,MAAM,YAAA,GAAe,sCAAA;AAUd,MAAM,mCAAmC,mBAAA,CAAoB;AAAA,EAIlE,WAAA,CAAY,MAAA,GAAgC,EAAC,EAAG;AAC9C,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAHzC;AAAA,IAAA,IAAA,CAAQ,WAAA,GAAc,KAAA;AAAA,EAItB;AAAA,EAEA,IAAA,GAAO;AACL,IAAA,OAAO;AAAA,MACL,IAAI,mCAAA;AAAA,QACF,WAAA;AAAA,QACA,CAAC,YAAY,CAAA;AAAA,QACb,CAAC,aAAA,KAAqC;AACpC,UAAA,MAAM,OAAO,aAAA,CAAc,IAAA;AAC3B,UAAA,IAAI,SAAA,CAAU,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA,EAAG;AACrC,YAAA,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,SAAA,EAAW,SAAS,CAAA;AAAA,UACxC;AACA,UAAA,IAAA,CAAK,KAAA,CAAM,KAAK,SAAA,EAAW,SAAA,EAAW,KAAK,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAC,CAAA;AACrE,UAAA,OAAO,aAAA;AAAA,QACT,CAAA;AA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AAS,IAAA;AAAA,UACP,IAAA;AAAA,UACA,CAAC,KAAc,MAAA,KAAoB;AACjC,YAAA,IAAI,GAAA,EAAK;AACP,cAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAM,iBAAA,EAAmB,OAAA,EAAS,kBAAkB,CAAA;AAAA,YACvE;AACA,YAAA,IAAA,CAAK,GAAA,EAAI;AAIT,YAAA,IAAI,EAAA,EAAI;AACN,cAAA,EAAA,CAAG,KAAK,MAAM,CAAA;AAAA,YAChB;AAAA,UACF,CAAA;AAAA,UACA;AAAA,SACF;AAAA,MACF,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,EACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/google-genai/index.ts"],"sourcesContent":["import type { GoogleGenAIOptions, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, GOOGLE_GENAI_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryGoogleGenAiInstrumentation } from './instrumentation';\n\nexport const instrumentGoogleGenAI = generateInstrumentOnce<GoogleGenAIOptions>(\n GOOGLE_GENAI_INTEGRATION_NAME,\n options => new SentryGoogleGenAiInstrumentation(options),\n);\n\nconst _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {\n return {\n name: GOOGLE_GENAI_INTEGRATION_NAME,\n setupOnce() {\n instrumentGoogleGenAI(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the Google Generative AI SDK.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments Google GenAI SDK client instances\n * to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.init({\n * integrations: [Sentry.googleGenAiIntegration()],\n * });\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record prompt messages (default: respects `sendDefaultPii` client option)\n * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options\n * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled\n *\n * @example\n * ```javascript\n * // Record inputs and outputs when sendDefaultPii is false\n * Sentry.init({\n * integrations: [\n * Sentry.googleGenAiIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of sendDefaultPii\n * Sentry.init({\n * sendDefaultPii: true,\n * integrations: [\n * Sentry.googleGenAiIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n */\nexport const googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,qBAAA,GAAwB,sBAAA;AAAA,EACnC,6BAAA;AAAA,EACA,CAAA,OAAA,KAAW,IAAI,gCAAA,CAAiC,OAAO;AACzD;AAEA,MAAM,uBAAA,IAA2B,CAAC,OAAA,GAA8B,EAAC,KAAM;AACrE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,6BAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,qBAAA,CAAsB,OAAO,CAAA;AAAA,IAC/B;AAAA,GACF;AACF,CAAA,CAAA;AAuDO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/google-genai/index.ts"],"sourcesContent":["import type { GoogleGenAIOptions, IntegrationFn } from '@sentry/core';\nimport { defineIntegration, GOOGLE_GENAI_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryGoogleGenAiInstrumentation } from './instrumentation';\n\nexport const instrumentGoogleGenAI = generateInstrumentOnce<GoogleGenAIOptions>(\n GOOGLE_GENAI_INTEGRATION_NAME,\n options => new SentryGoogleGenAiInstrumentation(options),\n);\n\nconst _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {\n return {\n name: GOOGLE_GENAI_INTEGRATION_NAME,\n setupOnce() {\n instrumentGoogleGenAI(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the Google Generative AI SDK.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments Google GenAI SDK client instances\n * to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.init({\n * integrations: [Sentry.googleGenAiIntegration()],\n * });\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`)\n * - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options\n * (or the deprecated `sendDefaultPii` option, for backwards compatibility)\n * - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config\n *\n * @example\n * ```javascript\n * // Always record inputs and outputs regardless of global dataCollection config\n * Sentry.init({\n * integrations: [\n * Sentry.googleGenAiIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of global dataCollection config\n * Sentry.init({\n * dataCollection: { genAI: { inputs: true, outputs: true } },\n * integrations: [\n * Sentry.googleGenAiIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n */\nexport const googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,qBAAA,GAAwB,sBAAA;AAAA,EACnC,6BAAA;AAAA,EACA,CAAA,OAAA,KAAW,IAAI,gCAAA,CAAiC,OAAO;AACzD;AAEA,MAAM,uBAAA,IAA2B,CAAC,OAAA,GAA8B,EAAC,KAAM;AACrE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,6BAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,qBAAA,CAAsB,OAAO,CAAA;AAAA,IAC/B;AAAA,GACF;AACF,CAAA,CAAA;AAwDO,MAAM,sBAAA,GAAyB,kBAAkB,uBAAuB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/langchain/index.ts"],"sourcesContent":["import type { IntegrationFn, LangChainOptions } from '@sentry/core';\nimport { defineIntegration, LANGCHAIN_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryLangChainInstrumentation } from './instrumentation';\n\nexport const instrumentLangChain = generateInstrumentOnce<LangChainOptions>(\n LANGCHAIN_INTEGRATION_NAME,\n options => new SentryLangChainInstrumentation(options),\n);\n\nconst _langChainIntegration = ((options: LangChainOptions = {}) => {\n return {\n name: LANGCHAIN_INTEGRATION_NAME,\n setupOnce() {\n instrumentLangChain(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for LangChain.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments LangChain runnable instances\n * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.\n *\n * **Important:** This integration automatically skips wrapping the OpenAI, Anthropic, and Google GenAI\n * providers to prevent duplicate spans when using LangChain with these AI providers.\n * LangChain handles the instrumentation for all underlying AI providers.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * Sentry.init({\n * integrations: [Sentry.langChainIntegration()],\n * sendDefaultPii: true, // Enable to record inputs/outputs\n * });\n *\n * // LangChain calls are automatically instrumented\n * const model = new ChatOpenAI();\n * await model.invoke(\"What is the capital of France?\");\n * ```\n *\n * ## Manual Callback Handler\n *\n * You can also manually add the Sentry callback handler alongside other callbacks:\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * const sentryHandler = Sentry.createLangChainCallbackHandler({\n * recordInputs: true,\n * recordOutputs: true\n * });\n *\n * const model = new ChatOpenAI();\n * await model.invoke(\n * \"What is the capital of France?\",\n * { callbacks: [sentryHandler, myOtherCallback] }\n * );\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)\n * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options\n * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled\n *\n * @example\n * ```javascript\n * // Record inputs and outputs when sendDefaultPii is false\n * Sentry.init({\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of sendDefaultPii\n * Sentry.init({\n * sendDefaultPii: true,\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n * ## Supported Events\n *\n * The integration captures the following LangChain lifecycle events:\n * - LLM/Chat Model: start, end, error (via callbacks)\n * - Chain: start, end, error (via callbacks)\n * - Tool: start, end, error (via callbacks)\n * - Embeddings: embedQuery, embedDocuments (via direct method wrapping)\n *\n */\nexport const langChainIntegration = defineIntegration(_langChainIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,mBAAA,GAAsB,sBAAA;AAAA,EACjC,0BAAA;AAAA,EACA,CAAA,OAAA,KAAW,IAAI,8BAAA,CAA+B,OAAO;AACvD;AAEA,MAAM,qBAAA,IAAyB,CAAC,OAAA,GAA4B,EAAC,KAAM;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,0BAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,mBAAA,CAAoB,OAAO,CAAA;AAAA,IAC7B;AAAA,GACF;AACF,CAAA,CAAA;AA8FO,MAAM,oBAAA,GAAuB,kBAAkB,qBAAqB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/langchain/index.ts"],"sourcesContent":["import type { IntegrationFn, LangChainOptions } from '@sentry/core';\nimport { defineIntegration, LANGCHAIN_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryLangChainInstrumentation } from './instrumentation';\n\nexport const instrumentLangChain = generateInstrumentOnce<LangChainOptions>(\n LANGCHAIN_INTEGRATION_NAME,\n options => new SentryLangChainInstrumentation(options),\n);\n\nconst _langChainIntegration = ((options: LangChainOptions = {}) => {\n return {\n name: LANGCHAIN_INTEGRATION_NAME,\n setupOnce() {\n instrumentLangChain(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for LangChain.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments LangChain runnable instances\n * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.\n *\n * **Important:** This integration automatically skips wrapping the OpenAI, Anthropic, and Google GenAI\n * providers to prevent duplicate spans when using LangChain with these AI providers.\n * LangChain handles the instrumentation for all underlying AI providers.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * Sentry.init({\n * integrations: [Sentry.langChainIntegration()],\n * dataCollection: { genAI: { inputs: true, outputs: true } }, // Enable to record inputs/outputs\n * });\n *\n * // LangChain calls are automatically instrumented\n * const model = new ChatOpenAI();\n * await model.invoke(\"What is the capital of France?\");\n * ```\n *\n * ## Manual Callback Handler\n *\n * You can also manually add the Sentry callback handler alongside other callbacks:\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * const sentryHandler = Sentry.createLangChainCallbackHandler({\n * recordInputs: true,\n * recordOutputs: true\n * });\n *\n * const model = new ChatOpenAI();\n * await model.invoke(\n * \"What is the capital of France?\",\n * { callbacks: [sentryHandler, myOtherCallback] }\n * );\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record input messages/prompts (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)\n * - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options\n * (or the deprecated `sendDefaultPii` option, for backwards compatibility)\n * - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config\n *\n * @example\n * ```javascript\n * // Always record inputs and outputs regardless of global dataCollection config\n * Sentry.init({\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of global dataCollection config\n * Sentry.init({\n * dataCollection: { genAI: { inputs: true, outputs: true } },\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n * ## Supported Events\n *\n * The integration captures the following LangChain lifecycle events:\n * - LLM/Chat Model: start, end, error (via callbacks)\n * - Chain: start, end, error (via callbacks)\n * - Tool: start, end, error (via callbacks)\n * - Embeddings: embedQuery, embedDocuments (via direct method wrapping)\n *\n */\nexport const langChainIntegration = defineIntegration(_langChainIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,mBAAA,GAAsB,sBAAA;AAAA,EACjC,0BAAA;AAAA,EACA,CAAA,OAAA,KAAW,IAAI,8BAAA,CAA+B,OAAO;AACvD;AAEA,MAAM,qBAAA,IAAyB,CAAC,OAAA,GAA4B,EAAC,KAAM;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,0BAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,mBAAA,CAAoB,OAAO,CAAA;AAAA,IAC7B;AAAA,GACF;AACF,CAAA,CAAA;AA+FO,MAAM,oBAAA,GAAuB,kBAAkB,qBAAqB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/langgraph/index.ts"],"sourcesContent":["import type { IntegrationFn, LangGraphOptions } from '@sentry/core';\nimport { defineIntegration, LANGGRAPH_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryLangGraphInstrumentation } from './instrumentation';\n\nexport const instrumentLangGraph = generateInstrumentOnce<LangGraphOptions>(\n LANGGRAPH_INTEGRATION_NAME,\n options => new SentryLangGraphInstrumentation(options),\n);\n\nconst _langGraphIntegration = ((options: LangGraphOptions = {}) => {\n return {\n name: LANGGRAPH_INTEGRATION_NAME,\n setupOnce() {\n instrumentLangGraph(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for LangGraph.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments LangGraph StateGraph and compiled graph instances\n * to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.init({\n * integrations: [Sentry.langGraphIntegration()],\n * });\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record prompt messages (default: follows `sendDefaultPii` or `dataCollection.genAI.inputs`)\n * - `recordOutputs`: Whether to record response text (default: follows `sendDefaultPii` or `dataCollection.genAI.outputs`)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs based on `sendDefaultPii` or `dataCollection.genAI` in your Sentry client options\n * - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config\n *\n * @example\n * ```javascript\n * // Always record inputs and outputs regardless of global dataCollection config\n * Sentry.init({\n * integrations: [\n * Sentry.langGraphIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of global dataCollection config\n * Sentry.init({\n * dataCollection: { genAI: { inputs: true, outputs: true } },\n * integrations: [\n * Sentry.langGraphIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n * ## Captured Operations\n *\n * The integration captures the following LangGraph operations:\n * - **Agent Creation** (`StateGraph.compile()`) - Creates a `gen_ai.create_agent` span\n * - **Agent Invocation** (`CompiledGraph.invoke()`) - Creates a `gen_ai.invoke_agent` span\n *\n * ## Captured Data\n *\n * When `recordInputs` and `recordOutputs` are enabled, the integration captures:\n * - Input messages from the graph state\n * - Output messages and LLM responses\n * - Tool calls made during agent execution\n * - Agent and graph names\n * - Available tools configured in the graph\n *\n */\nexport const langGraphIntegration = defineIntegration(_langGraphIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,mBAAA,GAAsB,sBAAA;AAAA,EACjC,0BAAA;AAAA,EACA,CAAA,OAAA,KAAW,IAAI,8BAAA,CAA+B,OAAO;AACvD;AAEA,MAAM,qBAAA,IAAyB,CAAC,OAAA,GAA4B,EAAC,KAAM;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,0BAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,mBAAA,CAAoB,OAAO,CAAA;AAAA,IAC7B;AAAA,GACF;AACF,CAAA,CAAA;AAsEO,MAAM,oBAAA,GAAuB,kBAAkB,qBAAqB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/langgraph/index.ts"],"sourcesContent":["import type { IntegrationFn, LangGraphOptions } from '@sentry/core';\nimport { defineIntegration, LANGGRAPH_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryLangGraphInstrumentation } from './instrumentation';\n\nexport const instrumentLangGraph = generateInstrumentOnce<LangGraphOptions>(\n LANGGRAPH_INTEGRATION_NAME,\n options => new SentryLangGraphInstrumentation(options),\n);\n\nconst _langGraphIntegration = ((options: LangGraphOptions = {}) => {\n return {\n name: LANGGRAPH_INTEGRATION_NAME,\n setupOnce() {\n instrumentLangGraph(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for LangGraph.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments LangGraph StateGraph and compiled graph instances\n * to capture telemetry data following OpenTelemetry Semantic Conventions for Generative AI.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.init({\n * integrations: [Sentry.langGraphIntegration()],\n * });\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record prompt messages (default: follows `dataCollection.genAI.inputs`, or the deprecated `sendDefaultPii` option)\n * - `recordOutputs`: Whether to record response text (default: follows `dataCollection.genAI.outputs`, or the deprecated `sendDefaultPii` option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs based on `dataCollection.genAI` in your Sentry client options\n * (or the deprecated `sendDefaultPii` option, for backwards compatibility)\n * - Integration-level `recordInputs`/`recordOutputs` options take precedence over global config\n *\n * @example\n * ```javascript\n * // Always record inputs and outputs regardless of global dataCollection config\n * Sentry.init({\n * integrations: [\n * Sentry.langGraphIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of global dataCollection config\n * Sentry.init({\n * dataCollection: { genAI: { inputs: true, outputs: true } },\n * integrations: [\n * Sentry.langGraphIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n * ## Captured Operations\n *\n * The integration captures the following LangGraph operations:\n * - **Agent Creation** (`StateGraph.compile()`) - Creates a `gen_ai.create_agent` span\n * - **Agent Invocation** (`CompiledGraph.invoke()`) - Creates a `gen_ai.invoke_agent` span\n *\n * ## Captured Data\n *\n * When `recordInputs` and `recordOutputs` are enabled, the integration captures:\n * - Input messages from the graph state\n * - Output messages and LLM responses\n * - Tool calls made during agent execution\n * - Agent and graph names\n * - Available tools configured in the graph\n *\n */\nexport const langGraphIntegration = defineIntegration(_langGraphIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,mBAAA,GAAsB,sBAAA;AAAA,EACjC,0BAAA;AAAA,EACA,CAAA,OAAA,KAAW,IAAI,8BAAA,CAA+B,OAAO;AACvD;AAEA,MAAM,qBAAA,IAAyB,CAAC,OAAA,GAA4B,EAAC,KAAM;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,0BAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,mBAAA,CAAoB,OAAO,CAAA;AAAA,IAC7B;AAAA,GACF;AACF,CAAA,CAAA;AAuEO,MAAM,oBAAA,GAAuB,kBAAkB,qBAAqB;;;;"}
@@ -4,8 +4,8 @@ import { SDK_VERSION } from '@sentry/core';
4
4
 
5
5
  const PACKAGE_NAME = "@sentry/instrumentation-lru-memoizer";
6
6
  class LruMemoizerInstrumentation extends InstrumentationBase {
7
- constructor(config = {}) {
8
- super(PACKAGE_NAME, SDK_VERSION, config);
7
+ constructor() {
8
+ super(PACKAGE_NAME, SDK_VERSION, {});
9
9
  }
10
10
  init() {
11
11
  return [
@@ -13,18 +13,15 @@ class LruMemoizerInstrumentation extends InstrumentationBase {
13
13
  "lru-memoizer",
14
14
  [">=1.3 <4"],
15
15
  (moduleExports) => {
16
- const asyncMemoizer = function() {
17
- const origMemoizer = moduleExports.apply(this, arguments);
18
- return function() {
19
- const modifiedArguments = [...arguments];
20
- const origCallback = modifiedArguments.pop();
16
+ const asyncMemoizer = function(...args) {
17
+ const origMemoizer = moduleExports.apply(this, args);
18
+ return function(...memoizerArgs) {
19
+ const origCallback = memoizerArgs.pop();
21
20
  const callbackWithContext = typeof origCallback === "function" ? context.bind(context.active(), origCallback) : origCallback;
22
- modifiedArguments.push(callbackWithContext);
23
- return origMemoizer.apply(this, modifiedArguments);
21
+ return origMemoizer.apply(this, [...memoizerArgs, callbackWithContext]);
24
22
  };
25
23
  };
26
- asyncMemoizer.sync = moduleExports.sync;
27
- return asyncMemoizer;
24
+ return Object.assign(asyncMemoizer, { sync: moduleExports.sync });
28
25
  },
29
26
  void 0
30
27
  // no need to disable as this instrumentation does not create any spans