@sentry/node 10.51.0 → 10.53.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 (93) hide show
  1. package/build/cjs/index.js +4 -4
  2. package/build/cjs/integrations/http.js +18 -145
  3. package/build/cjs/integrations/http.js.map +1 -1
  4. package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js +8 -8
  5. package/build/cjs/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -1
  6. package/build/cjs/integrations/tracing/google-genai/instrumentation.js +9 -9
  7. package/build/cjs/integrations/tracing/google-genai/instrumentation.js.map +1 -1
  8. package/build/cjs/integrations/tracing/index.js +21 -22
  9. package/build/cjs/integrations/tracing/index.js.map +1 -1
  10. package/build/cjs/integrations/tracing/langchain/instrumentation.js +12 -12
  11. package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -1
  12. package/build/cjs/integrations/tracing/langgraph/instrumentation.js +12 -12
  13. package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -1
  14. package/build/cjs/integrations/tracing/openai/instrumentation.js +11 -11
  15. package/build/cjs/integrations/tracing/openai/instrumentation.js.map +1 -1
  16. package/build/cjs/integrations/tracing/postgresjs.js +10 -10
  17. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  18. package/build/cjs/integrations/tracing/{redis.js → redis/index.js} +18 -10
  19. package/build/cjs/integrations/tracing/redis/index.js.map +1 -0
  20. package/build/cjs/integrations/tracing/redis/redis-dc-subscriber.js +186 -0
  21. package/build/cjs/integrations/tracing/redis/redis-dc-subscriber.js.map +1 -0
  22. package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +255 -0
  23. package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -0
  24. package/build/cjs/integrations/tracing/redis/vendored/redis-common.js +74 -0
  25. package/build/cjs/integrations/tracing/redis/vendored/redis-common.js.map +1 -0
  26. package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +685 -0
  27. package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -0
  28. package/build/cjs/integrations/tracing/redis/vendored/semconv.js +47 -0
  29. package/build/cjs/integrations/tracing/redis/vendored/semconv.js.map +1 -0
  30. package/build/cjs/utils/redisCache.js.map +1 -1
  31. package/build/esm/index.js +1 -1
  32. package/build/esm/integrations/http.js +21 -146
  33. package/build/esm/integrations/http.js.map +1 -1
  34. package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js +8 -8
  35. package/build/esm/integrations/tracing/anthropic-ai/instrumentation.js.map +1 -1
  36. package/build/esm/integrations/tracing/google-genai/instrumentation.js +9 -9
  37. package/build/esm/integrations/tracing/google-genai/instrumentation.js.map +1 -1
  38. package/build/esm/integrations/tracing/index.js +2 -3
  39. package/build/esm/integrations/tracing/index.js.map +1 -1
  40. package/build/esm/integrations/tracing/langchain/instrumentation.js +12 -12
  41. package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -1
  42. package/build/esm/integrations/tracing/langgraph/instrumentation.js +12 -12
  43. package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -1
  44. package/build/esm/integrations/tracing/openai/instrumentation.js +11 -11
  45. package/build/esm/integrations/tracing/openai/instrumentation.js.map +1 -1
  46. package/build/esm/integrations/tracing/postgresjs.js +10 -10
  47. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  48. package/build/esm/integrations/tracing/{redis.js → redis/index.js} +17 -9
  49. package/build/esm/integrations/tracing/redis/index.js.map +1 -0
  50. package/build/esm/integrations/tracing/redis/redis-dc-subscriber.js +184 -0
  51. package/build/esm/integrations/tracing/redis/redis-dc-subscriber.js.map +1 -0
  52. package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +253 -0
  53. package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -0
  54. package/build/esm/integrations/tracing/redis/vendored/redis-common.js +72 -0
  55. package/build/esm/integrations/tracing/redis/vendored/redis-common.js.map +1 -0
  56. package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +683 -0
  57. package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -0
  58. package/build/esm/integrations/tracing/redis/vendored/semconv.js +39 -0
  59. package/build/esm/integrations/tracing/redis/vendored/semconv.js.map +1 -0
  60. package/build/esm/package.json +1 -1
  61. package/build/esm/utils/redisCache.js.map +1 -1
  62. package/build/types/integrations/http.d.ts +8 -15
  63. package/build/types/integrations/http.d.ts.map +1 -1
  64. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  65. package/build/types/integrations/tracing/{redis.d.ts → redis/index.d.ts} +3 -3
  66. package/build/types/integrations/tracing/redis/index.d.ts.map +1 -0
  67. package/build/types/integrations/tracing/redis/redis-dc-subscriber.d.ts +17 -0
  68. package/build/types/integrations/tracing/redis/redis-dc-subscriber.d.ts.map +1 -0
  69. package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +15 -0
  70. package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -0
  71. package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts +6 -0
  72. package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts.map +1 -0
  73. package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts +16 -0
  74. package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -0
  75. package/build/types/integrations/tracing/redis/vendored/semconv.d.ts +8 -0
  76. package/build/types/integrations/tracing/redis/vendored/semconv.d.ts.map +1 -0
  77. package/build/types/integrations/tracing/redis/vendored/types.d.ts +58 -0
  78. package/build/types/integrations/tracing/redis/vendored/types.d.ts.map +1 -0
  79. package/build/types/utils/redisCache.d.ts +1 -1
  80. package/build/types/utils/redisCache.d.ts.map +1 -1
  81. package/build/types-ts3.8/integrations/http.d.ts +8 -15
  82. package/build/types-ts3.8/integrations/tracing/{redis.d.ts → redis/index.d.ts} +3 -3
  83. package/build/types-ts3.8/integrations/tracing/redis/redis-dc-subscriber.d.ts +17 -0
  84. package/build/types-ts3.8/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +15 -0
  85. package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-common.d.ts +6 -0
  86. package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-instrumentation.d.ts +16 -0
  87. package/build/types-ts3.8/integrations/tracing/redis/vendored/semconv.d.ts +8 -0
  88. package/build/types-ts3.8/integrations/tracing/redis/vendored/types.d.ts +58 -0
  89. package/build/types-ts3.8/utils/redisCache.d.ts +1 -1
  90. package/package.json +4 -6
  91. package/build/cjs/integrations/tracing/redis.js.map +0 -1
  92. package/build/esm/integrations/tracing/redis.js.map +0 -1
  93. package/build/types/integrations/tracing/redis.d.ts.map +0 -1
@@ -0,0 +1,253 @@
1
+ import { trace, context, SpanKind, diag, SpanStatusCode } from '@opentelemetry/api';
2
+ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
3
+ import { InstrumentationBase, semconvStabilityFromStr, InstrumentationNodeModuleDefinition, isWrapped, SemconvStability, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
4
+ import { ATTR_DB_SYSTEM_NAME, ATTR_DB_QUERY_TEXT, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT } from '@opentelemetry/semantic-conventions';
5
+ import { defaultDbStatementSerializer } from './redis-common.js';
6
+ import { DB_SYSTEM_VALUE_REDIS, ATTR_DB_SYSTEM, ATTR_DB_STATEMENT, ATTR_DB_CONNECTION_STRING, DB_SYSTEM_NAME_VALUE_REDIS, ATTR_NET_PEER_NAME, ATTR_NET_PEER_PORT } from './semconv.js';
7
+
8
+ /*
9
+ * Copyright The OpenTelemetry Authors
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * https://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ *
23
+ * NOTICE from the Sentry authors:
24
+ * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/instrumentation-ioredis-v0.62.0/packages/instrumentation-ioredis
25
+ * - Upstream version: @opentelemetry/instrumentation-ioredis@0.62.0
26
+ * - Minor TypeScript adjustments for this repository's compiler settings
27
+ */
28
+ /* eslint-disable -- vendored @opentelemetry/instrumentation-ioredis */
29
+
30
+
31
+ const PACKAGE_NAME = '@opentelemetry/instrumentation-ioredis';
32
+ const PACKAGE_VERSION = '0.62.0';
33
+
34
+ // ---- utils ----
35
+
36
+ function endSpan(span, err) {
37
+ if (err) {
38
+ span.recordException(err);
39
+ span.setStatus({
40
+ code: SpanStatusCode.ERROR,
41
+ message: err.message,
42
+ });
43
+ }
44
+ span.end();
45
+ }
46
+
47
+ // ---- IORedisInstrumentation ----
48
+
49
+ const DEFAULT_CONFIG = {
50
+ requireParentSpan: true,
51
+ };
52
+
53
+ class IORedisInstrumentation extends InstrumentationBase {
54
+
55
+ constructor(config = {}) {
56
+ super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });
57
+ this._setSemconvStabilityFromEnv();
58
+ }
59
+
60
+ _setSemconvStabilityFromEnv() {
61
+ this._netSemconvStability = semconvStabilityFromStr('http', process.env['OTEL_SEMCONV_STABILITY_OPT_IN']);
62
+ this._dbSemconvStability = semconvStabilityFromStr('database', process.env['OTEL_SEMCONV_STABILITY_OPT_IN']);
63
+ }
64
+
65
+ setConfig(config = {}) {
66
+ super.setConfig({ ...DEFAULT_CONFIG, ...config });
67
+ }
68
+
69
+ init() {
70
+ return [
71
+ new InstrumentationNodeModuleDefinition(
72
+ 'ioredis',
73
+ ['>=2.0.0 <6'],
74
+ (module, moduleVersion) => {
75
+ const moduleExports =
76
+ module[Symbol.toStringTag] === 'Module'
77
+ ? module.default // ESM
78
+ : module; // CommonJS
79
+ if (isWrapped(moduleExports.prototype.sendCommand)) {
80
+ this._unwrap(moduleExports.prototype, 'sendCommand');
81
+ }
82
+ this._wrap(moduleExports.prototype, 'sendCommand', this._patchSendCommand(moduleVersion));
83
+ if (isWrapped(moduleExports.prototype.connect)) {
84
+ this._unwrap(moduleExports.prototype, 'connect');
85
+ }
86
+ this._wrap(moduleExports.prototype, 'connect', this._patchConnection());
87
+ return module;
88
+ },
89
+ (module) => {
90
+ if (module === undefined) return;
91
+ const moduleExports =
92
+ module[Symbol.toStringTag] === 'Module'
93
+ ? module.default // ESM
94
+ : module; // CommonJS
95
+ this._unwrap(moduleExports.prototype, 'sendCommand');
96
+ this._unwrap(moduleExports.prototype, 'connect');
97
+ },
98
+ ),
99
+ ];
100
+ }
101
+
102
+ _patchSendCommand(moduleVersion) {
103
+ return (original) => {
104
+ return this._traceSendCommand(original, moduleVersion);
105
+ };
106
+ }
107
+
108
+ _patchConnection() {
109
+ return (original) => {
110
+ return this._traceConnection(original);
111
+ };
112
+ }
113
+
114
+ _traceSendCommand(original, moduleVersion) {
115
+ const instrumentation = this;
116
+ return function ( cmd) {
117
+ if (arguments.length < 1 || typeof cmd !== 'object') {
118
+ return original.apply(this, arguments);
119
+ }
120
+ const config = instrumentation.getConfig();
121
+ const dbStatementSerializer = config.dbStatementSerializer || defaultDbStatementSerializer;
122
+ const hasNoParentSpan = trace.getSpan(context.active()) === undefined;
123
+ if (config.requireParentSpan === true && hasNoParentSpan) {
124
+ return original.apply(this, arguments);
125
+ }
126
+ const attributes = {};
127
+ const { host, port } = this.options;
128
+ const dbQueryText = dbStatementSerializer(cmd.name, cmd.args);
129
+ if (instrumentation._dbSemconvStability & SemconvStability.OLD) {
130
+ attributes[ATTR_DB_SYSTEM] = DB_SYSTEM_VALUE_REDIS;
131
+ attributes[ATTR_DB_STATEMENT] = dbQueryText;
132
+ attributes[ATTR_DB_CONNECTION_STRING] = `redis://${host}:${port}`;
133
+ }
134
+ if (instrumentation._dbSemconvStability & SemconvStability.STABLE) {
135
+ attributes[ATTR_DB_SYSTEM_NAME] = DB_SYSTEM_NAME_VALUE_REDIS;
136
+ attributes[ATTR_DB_QUERY_TEXT] = dbQueryText;
137
+ }
138
+ if (instrumentation._netSemconvStability & SemconvStability.OLD) {
139
+ attributes[ATTR_NET_PEER_NAME] = host;
140
+ attributes[ATTR_NET_PEER_PORT] = port;
141
+ }
142
+ if (instrumentation._netSemconvStability & SemconvStability.STABLE) {
143
+ attributes[ATTR_SERVER_ADDRESS] = host;
144
+ attributes[ATTR_SERVER_PORT] = port;
145
+ }
146
+ attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.db.otel.redis';
147
+ const span = instrumentation.tracer.startSpan(cmd.name, {
148
+ kind: SpanKind.CLIENT,
149
+ attributes,
150
+ });
151
+ const { requestHook } = config;
152
+ if (requestHook) {
153
+ safeExecuteInTheMiddle(
154
+ () =>
155
+ requestHook(span, {
156
+ moduleVersion,
157
+ cmdName: cmd.name,
158
+ cmdArgs: cmd.args,
159
+ }),
160
+ (e) => {
161
+ if (e) {
162
+ diag.error('ioredis instrumentation: request hook failed', e);
163
+ }
164
+ },
165
+ true,
166
+ );
167
+ }
168
+ try {
169
+ const result = original.apply(this, arguments);
170
+ const origResolve = cmd.resolve;
171
+ cmd.resolve = function (result) {
172
+ safeExecuteInTheMiddle(
173
+ () => config.responseHook?.(span, cmd.name, cmd.args, result),
174
+ (e) => {
175
+ if (e) {
176
+ diag.error('ioredis instrumentation: response hook failed', e);
177
+ }
178
+ },
179
+ true,
180
+ );
181
+ endSpan(span, null);
182
+ origResolve(result);
183
+ };
184
+ const origReject = cmd.reject;
185
+ cmd.reject = function (err) {
186
+ endSpan(span, err);
187
+ origReject(err);
188
+ };
189
+ return result;
190
+ } catch (error) {
191
+ endSpan(span, error );
192
+ throw error;
193
+ }
194
+ };
195
+ }
196
+
197
+ _traceConnection(original) {
198
+ const instrumentation = this;
199
+ return function () {
200
+ const hasNoParentSpan = trace.getSpan(context.active()) === undefined;
201
+ if (instrumentation.getConfig().requireParentSpan === true && hasNoParentSpan) {
202
+ return original.apply(this, arguments);
203
+ }
204
+ const attributes = {};
205
+ const { host, port } = this.options;
206
+ if (instrumentation._dbSemconvStability & SemconvStability.OLD) {
207
+ attributes[ATTR_DB_SYSTEM] = DB_SYSTEM_VALUE_REDIS;
208
+ attributes[ATTR_DB_STATEMENT] = 'connect';
209
+ attributes[ATTR_DB_CONNECTION_STRING] = `redis://${host}:${port}`;
210
+ }
211
+ if (instrumentation._dbSemconvStability & SemconvStability.STABLE) {
212
+ attributes[ATTR_DB_SYSTEM_NAME] = DB_SYSTEM_NAME_VALUE_REDIS;
213
+ attributes[ATTR_DB_QUERY_TEXT] = 'connect';
214
+ }
215
+ if (instrumentation._netSemconvStability & SemconvStability.OLD) {
216
+ attributes[ATTR_NET_PEER_NAME] = host;
217
+ attributes[ATTR_NET_PEER_PORT] = port;
218
+ }
219
+ if (instrumentation._netSemconvStability & SemconvStability.STABLE) {
220
+ attributes[ATTR_SERVER_ADDRESS] = host;
221
+ attributes[ATTR_SERVER_PORT] = port;
222
+ }
223
+ attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.db.otel.redis';
224
+ const span = instrumentation.tracer.startSpan('connect', {
225
+ kind: SpanKind.CLIENT,
226
+ attributes,
227
+ });
228
+ try {
229
+ const result = original.apply(this, arguments);
230
+ if (typeof result?.then === 'function') {
231
+ return result.then(
232
+ (value) => {
233
+ endSpan(span, null);
234
+ return value;
235
+ },
236
+ (error) => {
237
+ endSpan(span, error);
238
+ return Promise.reject(error);
239
+ },
240
+ );
241
+ }
242
+ endSpan(span, null);
243
+ return result;
244
+ } catch (error) {
245
+ endSpan(span, error );
246
+ throw error;
247
+ }
248
+ };
249
+ }
250
+ }
251
+
252
+ export { IORedisInstrumentation };
253
+ //# sourceMappingURL=ioredis-instrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ioredis-instrumentation.js","sources":["../../../../../../src/integrations/tracing/redis/vendored/ioredis-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/instrumentation-ioredis-v0.62.0/packages/instrumentation-ioredis\n * - Upstream version: @opentelemetry/instrumentation-ioredis@0.62.0\n * - Minor TypeScript adjustments for this repository's compiler settings\n */\n/* eslint-disable -- vendored @opentelemetry/instrumentation-ioredis */\n\nimport { context, diag, SpanKind, SpanStatusCode, trace } from '@opentelemetry/api';\nimport type { Span } from '@opentelemetry/api';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n safeExecuteInTheMiddle,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_SYSTEM_NAME,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\n\nimport { defaultDbStatementSerializer } from './redis-common';\nimport {\n ATTR_DB_CONNECTION_STRING,\n ATTR_DB_STATEMENT,\n ATTR_DB_SYSTEM,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n DB_SYSTEM_NAME_VALUE_REDIS,\n DB_SYSTEM_VALUE_REDIS,\n} from './semconv';\nimport type { IORedisInstrumentationConfig } from './types';\n\nconst PACKAGE_NAME = '@opentelemetry/instrumentation-ioredis';\nconst PACKAGE_VERSION = '0.62.0';\n\n// ---- utils ----\n\nfunction endSpan(span: Span, err: Error | null | undefined): void {\n if (err) {\n span.recordException(err);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n }\n span.end();\n}\n\n// ---- IORedisInstrumentation ----\n\nconst DEFAULT_CONFIG: IORedisInstrumentationConfig = {\n requireParentSpan: true,\n};\n\nexport class IORedisInstrumentation extends InstrumentationBase<IORedisInstrumentationConfig> {\n _netSemconvStability!: SemconvStability;\n _dbSemconvStability!: SemconvStability;\n\n constructor(config: IORedisInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });\n this._setSemconvStabilityFromEnv();\n }\n\n _setSemconvStabilityFromEnv(): void {\n this._netSemconvStability = semconvStabilityFromStr('http', process.env['OTEL_SEMCONV_STABILITY_OPT_IN']);\n this._dbSemconvStability = semconvStabilityFromStr('database', process.env['OTEL_SEMCONV_STABILITY_OPT_IN']);\n }\n\n override setConfig(config: IORedisInstrumentationConfig = {}): void {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'ioredis',\n ['>=2.0.0 <6'],\n (module: any, moduleVersion?: string) => {\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n if (isWrapped(moduleExports.prototype.sendCommand)) {\n this._unwrap(moduleExports.prototype, 'sendCommand');\n }\n this._wrap(moduleExports.prototype, 'sendCommand', this._patchSendCommand(moduleVersion));\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n this._wrap(moduleExports.prototype, 'connect', this._patchConnection());\n return module;\n },\n (module: any) => {\n if (module === undefined) return;\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n this._unwrap(moduleExports.prototype, 'sendCommand');\n this._unwrap(moduleExports.prototype, 'connect');\n },\n ),\n ];\n }\n\n private _patchSendCommand(moduleVersion?: string) {\n return (original: Function) => {\n return this._traceSendCommand(original, moduleVersion);\n };\n }\n\n private _patchConnection() {\n return (original: Function) => {\n return this._traceConnection(original);\n };\n }\n\n private _traceSendCommand(original: Function, moduleVersion?: string) {\n const instrumentation = this;\n return function (this: any, cmd: any) {\n if (arguments.length < 1 || typeof cmd !== 'object') {\n return original.apply(this, arguments);\n }\n const config = instrumentation.getConfig();\n const dbStatementSerializer = config.dbStatementSerializer || defaultDbStatementSerializer;\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (config.requireParentSpan === true && hasNoParentSpan) {\n return original.apply(this, arguments);\n }\n const attributes: Record<string, any> = {};\n const { host, port } = this.options;\n const dbQueryText = dbStatementSerializer(cmd.name, cmd.args);\n if (instrumentation._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_SYSTEM] = DB_SYSTEM_VALUE_REDIS;\n attributes[ATTR_DB_STATEMENT] = dbQueryText;\n attributes[ATTR_DB_CONNECTION_STRING] = `redis://${host}:${port}`;\n }\n if (instrumentation._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_SYSTEM_NAME] = DB_SYSTEM_NAME_VALUE_REDIS;\n attributes[ATTR_DB_QUERY_TEXT] = dbQueryText;\n }\n if (instrumentation._netSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_NET_PEER_NAME] = host;\n attributes[ATTR_NET_PEER_PORT] = port;\n }\n if (instrumentation._netSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_SERVER_ADDRESS] = host;\n attributes[ATTR_SERVER_PORT] = port;\n }\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.db.otel.redis';\n const span = instrumentation.tracer.startSpan(cmd.name, {\n kind: SpanKind.CLIENT,\n attributes,\n });\n const { requestHook } = config;\n if (requestHook) {\n safeExecuteInTheMiddle(\n () =>\n requestHook(span, {\n moduleVersion,\n cmdName: cmd.name,\n cmdArgs: cmd.args,\n }),\n (e: Error | undefined) => {\n if (e) {\n diag.error('ioredis instrumentation: request hook failed', e);\n }\n },\n true,\n );\n }\n try {\n const result = original.apply(this, arguments);\n const origResolve = cmd.resolve;\n cmd.resolve = function (result: unknown) {\n safeExecuteInTheMiddle(\n () => config.responseHook?.(span, cmd.name, cmd.args, result),\n (e: Error | undefined) => {\n if (e) {\n diag.error('ioredis instrumentation: response hook failed', e);\n }\n },\n true,\n );\n endSpan(span, null);\n origResolve(result);\n };\n const origReject = cmd.reject;\n cmd.reject = function (err: Error) {\n endSpan(span, err);\n origReject(err);\n };\n return result;\n } catch (error) {\n endSpan(span, error as Error);\n throw error;\n }\n };\n }\n\n private _traceConnection(original: Function) {\n const instrumentation = this;\n return function (this: any) {\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (instrumentation.getConfig().requireParentSpan === true && hasNoParentSpan) {\n return original.apply(this, arguments);\n }\n const attributes: Record<string, any> = {};\n const { host, port } = this.options;\n if (instrumentation._dbSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_DB_SYSTEM] = DB_SYSTEM_VALUE_REDIS;\n attributes[ATTR_DB_STATEMENT] = 'connect';\n attributes[ATTR_DB_CONNECTION_STRING] = `redis://${host}:${port}`;\n }\n if (instrumentation._dbSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_DB_SYSTEM_NAME] = DB_SYSTEM_NAME_VALUE_REDIS;\n attributes[ATTR_DB_QUERY_TEXT] = 'connect';\n }\n if (instrumentation._netSemconvStability & SemconvStability.OLD) {\n attributes[ATTR_NET_PEER_NAME] = host;\n attributes[ATTR_NET_PEER_PORT] = port;\n }\n if (instrumentation._netSemconvStability & SemconvStability.STABLE) {\n attributes[ATTR_SERVER_ADDRESS] = host;\n attributes[ATTR_SERVER_PORT] = port;\n }\n attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.db.otel.redis';\n const span = instrumentation.tracer.startSpan('connect', {\n kind: SpanKind.CLIENT,\n attributes,\n });\n try {\n const result = original.apply(this, arguments);\n if (typeof result?.then === 'function') {\n return result.then(\n (value: unknown) => {\n endSpan(span, null);\n return value;\n },\n (error: Error) => {\n endSpan(span, error);\n return Promise.reject(error);\n },\n );\n }\n endSpan(span, null);\n return result;\n } catch (error) {\n endSpan(span, error as Error);\n throw error;\n }\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAgCA,MAAM,YAAA,GAAe,wCAAwC;AAC7D,MAAM,eAAA,GAAkB,QAAQ;;AAEhC;;AAEA,SAAS,OAAO,CAAC,IAAI,EAAQ,GAAG,EAAkC;AAClE,EAAE,IAAI,GAAG,EAAE;AACX,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC;AAC7B,IAAI,IAAI,CAAC,SAAS,CAAC;AACnB,MAAM,IAAI,EAAE,cAAc,CAAC,KAAK;AAChC,MAAM,OAAO,EAAE,GAAG,CAAC,OAAO;AAC1B,KAAK,CAAC;AACN,EAAE;AACF,EAAE,IAAI,CAAC,GAAG,EAAE;AACZ;;AAEA;;AAEA,MAAM,cAAc,GAAiC;AACrD,EAAE,iBAAiB,EAAE,IAAI;AACzB,CAAC;;AAEM,MAAM,sBAAA,SAA+B,mBAAmB,CAA+B;;AAI9F,EAAE,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,MAAA,EAAQ,CAAC;AAC1E,IAAI,IAAI,CAAC,2BAA2B,EAAE;AACtC,EAAE;;AAEF,EAAE,2BAA2B,GAAS;AACtC,IAAI,IAAI,CAAC,oBAAA,GAAuB,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CA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right The OpenTelemetry Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ * NOTICE from the Sentry authors:
17
+ * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/instrumentation-redis-v0.62.0/packages/redis-common
18
+ * - Upstream version: @opentelemetry/redis-common@0.38.2
19
+ * - Minor TypeScript adjustments for this repository's compiler settings
20
+ */
21
+ /* eslint-disable -- vendored @opentelemetry/redis-common */
22
+
23
+ /**
24
+ * List of regexes and the number of arguments that should be serialized for matching commands.
25
+ * For example, HSET should serialize which key and field it's operating on, but not its value.
26
+ * Setting the subset to -1 will serialize all arguments.
27
+ * Commands without a match will have their first argument serialized.
28
+ *
29
+ * Refer to https://redis.io/commands/ for the full list.
30
+ */
31
+ const serializationSubsets = [
32
+ {
33
+ regex: /^ECHO/i,
34
+ args: 0,
35
+ },
36
+ {
37
+ regex: /^(LPUSH|MSET|PFA|PUBLISH|RPUSH|SADD|SET|SPUBLISH|XADD|ZADD)/i,
38
+ args: 1,
39
+ },
40
+ {
41
+ regex: /^(HSET|HMSET|LSET|LINSERT)/i,
42
+ args: 2,
43
+ },
44
+ {
45
+ regex:
46
+ /^(ACL|BIT|B[LRZ]|CLIENT|CLUSTER|CONFIG|COMMAND|DECR|DEL|EVAL|EX|FUNCTION|GEO|GET|HINCR|HMGET|HSCAN|INCR|L[TRLM]|MEMORY|P[EFISTU]|RPOP|S[CDIMORSU]|XACK|X[CDGILPRT]|Z[CDILMPRS])/i,
47
+ args: -1,
48
+ },
49
+ ];
50
+
51
+ /**
52
+ * Given the redis command name and arguments, return a combination of the
53
+ * command name + the allowed arguments according to `serializationSubsets`.
54
+ */
55
+ const defaultDbStatementSerializer = (
56
+ cmdName,
57
+ cmdArgs,
58
+ ) => {
59
+ if (Array.isArray(cmdArgs) && cmdArgs.length) {
60
+ const nArgsToSerialize = serializationSubsets.find(({ regex }) => regex.test(cmdName))?.args ?? 0;
61
+ const argsToSerialize =
62
+ nArgsToSerialize >= 0 ? cmdArgs.slice(0, nArgsToSerialize) : cmdArgs.slice();
63
+ if (cmdArgs.length > argsToSerialize.length) {
64
+ argsToSerialize.push(`[${cmdArgs.length - nArgsToSerialize} other arguments]`);
65
+ }
66
+ return `${cmdName} ${argsToSerialize.join(' ')}`;
67
+ }
68
+ return cmdName;
69
+ };
70
+
71
+ export { defaultDbStatementSerializer };
72
+ //# sourceMappingURL=redis-common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis-common.js","sources":["../../../../../../src/integrations/tracing/redis/vendored/redis-common.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/instrumentation-redis-v0.62.0/packages/redis-common\n * - Upstream version: @opentelemetry/redis-common@0.38.2\n * - Minor TypeScript adjustments for this repository's compiler settings\n */\n/* eslint-disable -- vendored @opentelemetry/redis-common */\n\n/**\n * List of regexes and the number of arguments that should be serialized for matching commands.\n * For example, HSET should serialize which key and field it's operating on, but not its value.\n * Setting the subset to -1 will serialize all arguments.\n * Commands without a match will have their first argument serialized.\n *\n * Refer to https://redis.io/commands/ for the full list.\n */\nconst serializationSubsets = [\n {\n regex: /^ECHO/i,\n args: 0,\n },\n {\n regex: /^(LPUSH|MSET|PFA|PUBLISH|RPUSH|SADD|SET|SPUBLISH|XADD|ZADD)/i,\n args: 1,\n },\n {\n regex: /^(HSET|HMSET|LSET|LINSERT)/i,\n args: 2,\n },\n {\n regex:\n /^(ACL|BIT|B[LRZ]|CLIENT|CLUSTER|CONFIG|COMMAND|DECR|DEL|EVAL|EX|FUNCTION|GEO|GET|HINCR|HMGET|HSCAN|INCR|L[TRLM]|MEMORY|P[EFISTU]|RPOP|S[CDIMORSU]|XACK|X[CDGILPRT]|Z[CDILMPRS])/i,\n args: -1,\n },\n];\n\n/**\n * Given the redis command name and arguments, return a combination of the\n * command name + the allowed arguments according to `serializationSubsets`.\n */\nexport const defaultDbStatementSerializer = (\n cmdName: string,\n cmdArgs: Array<string | Buffer | number | any[]>,\n): string => {\n if (Array.isArray(cmdArgs) && cmdArgs.length) {\n const nArgsToSerialize = serializationSubsets.find(({ regex }) => regex.test(cmdName))?.args ?? 0;\n const argsToSerialize: Array<string | Buffer | number | any[]> =\n nArgsToSerialize >= 0 ? cmdArgs.slice(0, nArgsToSerialize) : cmdArgs.slice();\n if (cmdArgs.length > argsToSerialize.length) {\n argsToSerialize.push(`[${cmdArgs.length - nArgsToSerialize} other arguments]`);\n }\n return `${cmdName} ${argsToSerialize.join(' ')}`;\n }\n return cmdName;\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,uBAAuB;AAC7B,EAAE;AACF,IAAI,KAAK,EAAE,QAAQ;AACnB,IAAI,IAAI,EAAE,CAAC;AACX,GAAG;AACH,EAAE;AACF,IAAI,KAAK,EAAE,8DAA8D;AACzE,IAAI,IAAI,EAAE,CAAC;AAC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