@opentelemetry/instrumentation-ioredis 0.35.2 → 0.35.3

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.
@@ -8,7 +8,7 @@ export declare class IORedisInstrumentation extends InstrumentationBase<any> {
8
8
  */
9
9
  private _patchSendCommand;
10
10
  private _patchConnection;
11
- private traceSendCommand;
12
- private traceConnection;
11
+ private _traceSendCommand;
12
+ private _traceConnection;
13
13
  }
14
14
  //# sourceMappingURL=instrumentation.d.ts.map
@@ -29,104 +29,13 @@ const DEFAULT_CONFIG = {
29
29
  class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
30
30
  constructor(_config = {}) {
31
31
  super('@opentelemetry/instrumentation-ioredis', version_1.VERSION, Object.assign({}, DEFAULT_CONFIG, _config));
32
- this.traceSendCommand = (original, moduleVersion) => {
33
- const instrumentation = this;
34
- return function (cmd) {
35
- if (arguments.length < 1 || typeof cmd !== 'object') {
36
- return original.apply(this, arguments);
37
- }
38
- const config = instrumentation.getConfig();
39
- const dbStatementSerializer = (config === null || config === void 0 ? void 0 : config.dbStatementSerializer) || redis_common_1.defaultDbStatementSerializer;
40
- const hasNoParentSpan = api_1.trace.getSpan(api_1.context.active()) === undefined;
41
- if ((config === null || config === void 0 ? void 0 : config.requireParentSpan) === true && hasNoParentSpan) {
42
- return original.apply(this, arguments);
43
- }
44
- const span = instrumentation.tracer.startSpan(cmd.name, {
45
- kind: api_1.SpanKind.CLIENT,
46
- attributes: {
47
- [semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.REDIS,
48
- [semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: dbStatementSerializer(cmd.name, cmd.args),
49
- },
50
- });
51
- if (config === null || config === void 0 ? void 0 : config.requestHook) {
52
- (0, instrumentation_2.safeExecuteInTheMiddle)(() => config === null || config === void 0 ? void 0 : config.requestHook(span, {
53
- moduleVersion,
54
- cmdName: cmd.name,
55
- cmdArgs: cmd.args,
56
- }), e => {
57
- if (e) {
58
- api_1.diag.error('ioredis instrumentation: request hook failed', e);
59
- }
60
- }, true);
61
- }
62
- const { host, port } = this.options;
63
- span.setAttributes({
64
- [semantic_conventions_1.SemanticAttributes.NET_PEER_NAME]: host,
65
- [semantic_conventions_1.SemanticAttributes.NET_PEER_PORT]: port,
66
- [semantic_conventions_1.SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,
67
- });
68
- try {
69
- const result = original.apply(this, arguments);
70
- const origResolve = cmd.resolve;
71
- /* eslint-disable @typescript-eslint/no-explicit-any */
72
- cmd.resolve = function (result) {
73
- (0, instrumentation_2.safeExecuteInTheMiddle)(() => { var _a; return (_a = config === null || config === void 0 ? void 0 : config.responseHook) === null || _a === void 0 ? void 0 : _a.call(config, span, cmd.name, cmd.args, result); }, e => {
74
- if (e) {
75
- api_1.diag.error('ioredis instrumentation: response hook failed', e);
76
- }
77
- }, true);
78
- (0, utils_1.endSpan)(span, null);
79
- origResolve(result);
80
- };
81
- const origReject = cmd.reject;
82
- cmd.reject = function (err) {
83
- (0, utils_1.endSpan)(span, err);
84
- origReject(err);
85
- };
86
- return result;
87
- }
88
- catch (error) {
89
- (0, utils_1.endSpan)(span, error);
90
- throw error;
91
- }
92
- };
93
- };
94
- this.traceConnection = (original) => {
95
- const instrumentation = this;
96
- return function () {
97
- const config = instrumentation.getConfig();
98
- const hasNoParentSpan = api_1.trace.getSpan(api_1.context.active()) === undefined;
99
- if ((config === null || config === void 0 ? void 0 : config.requireParentSpan) === true && hasNoParentSpan) {
100
- return original.apply(this, arguments);
101
- }
102
- const span = instrumentation.tracer.startSpan('connect', {
103
- kind: api_1.SpanKind.CLIENT,
104
- attributes: {
105
- [semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.REDIS,
106
- [semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: 'connect',
107
- },
108
- });
109
- const { host, port } = this.options;
110
- span.setAttributes({
111
- [semantic_conventions_1.SemanticAttributes.NET_PEER_NAME]: host,
112
- [semantic_conventions_1.SemanticAttributes.NET_PEER_PORT]: port,
113
- [semantic_conventions_1.SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,
114
- });
115
- try {
116
- const client = original.apply(this, arguments);
117
- (0, utils_1.endSpan)(span, null);
118
- return client;
119
- }
120
- catch (error) {
121
- (0, utils_1.endSpan)(span, error);
122
- throw error;
123
- }
124
- };
125
- };
126
32
  }
127
33
  init() {
128
34
  return [
129
- new instrumentation_1.InstrumentationNodeModuleDefinition('ioredis', ['>1', '<6'], (moduleExports, moduleVersion) => {
35
+ new instrumentation_1.InstrumentationNodeModuleDefinition('ioredis', ['>1', '<6'], (module, moduleVersion) => {
36
+ const moduleExports = module[Symbol.toStringTag] === 'Module'
37
+ ? module.default // ESM
38
+ : module; // CommonJS
130
39
  api_1.diag.debug('Applying patch for ioredis');
131
40
  if ((0, instrumentation_1.isWrapped)(moduleExports.prototype.sendCommand)) {
132
41
  this._unwrap(moduleExports.prototype, 'sendCommand');
@@ -136,10 +45,13 @@ class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
136
45
  this._unwrap(moduleExports.prototype, 'connect');
137
46
  }
138
47
  this._wrap(moduleExports.prototype, 'connect', this._patchConnection());
139
- return moduleExports;
140
- }, moduleExports => {
141
- if (moduleExports === undefined)
48
+ return module;
49
+ }, module => {
50
+ if (module === undefined)
142
51
  return;
52
+ const moduleExports = module[Symbol.toStringTag] === 'Module'
53
+ ? module.default // ESM
54
+ : module; // CommonJS
143
55
  api_1.diag.debug('Removing patch for ioredis');
144
56
  this._unwrap(moduleExports.prototype, 'sendCommand');
145
57
  this._unwrap(moduleExports.prototype, 'connect');
@@ -151,12 +63,106 @@ class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
151
63
  */
152
64
  _patchSendCommand(moduleVersion) {
153
65
  return (original) => {
154
- return this.traceSendCommand(original, moduleVersion);
66
+ return this._traceSendCommand(original, moduleVersion);
155
67
  };
156
68
  }
157
69
  _patchConnection() {
158
70
  return (original) => {
159
- return this.traceConnection(original);
71
+ return this._traceConnection(original);
72
+ };
73
+ }
74
+ _traceSendCommand(original, moduleVersion) {
75
+ const instrumentation = this;
76
+ return function (cmd) {
77
+ if (arguments.length < 1 || typeof cmd !== 'object') {
78
+ return original.apply(this, arguments);
79
+ }
80
+ const config = instrumentation.getConfig();
81
+ const dbStatementSerializer = (config === null || config === void 0 ? void 0 : config.dbStatementSerializer) || redis_common_1.defaultDbStatementSerializer;
82
+ const hasNoParentSpan = api_1.trace.getSpan(api_1.context.active()) === undefined;
83
+ if ((config === null || config === void 0 ? void 0 : config.requireParentSpan) === true && hasNoParentSpan) {
84
+ return original.apply(this, arguments);
85
+ }
86
+ const span = instrumentation.tracer.startSpan(cmd.name, {
87
+ kind: api_1.SpanKind.CLIENT,
88
+ attributes: {
89
+ [semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.REDIS,
90
+ [semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: dbStatementSerializer(cmd.name, cmd.args),
91
+ },
92
+ });
93
+ if (config === null || config === void 0 ? void 0 : config.requestHook) {
94
+ (0, instrumentation_2.safeExecuteInTheMiddle)(() => config === null || config === void 0 ? void 0 : config.requestHook(span, {
95
+ moduleVersion,
96
+ cmdName: cmd.name,
97
+ cmdArgs: cmd.args,
98
+ }), e => {
99
+ if (e) {
100
+ api_1.diag.error('ioredis instrumentation: request hook failed', e);
101
+ }
102
+ }, true);
103
+ }
104
+ const { host, port } = this.options;
105
+ span.setAttributes({
106
+ [semantic_conventions_1.SemanticAttributes.NET_PEER_NAME]: host,
107
+ [semantic_conventions_1.SemanticAttributes.NET_PEER_PORT]: port,
108
+ [semantic_conventions_1.SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,
109
+ });
110
+ try {
111
+ const result = original.apply(this, arguments);
112
+ const origResolve = cmd.resolve;
113
+ /* eslint-disable @typescript-eslint/no-explicit-any */
114
+ cmd.resolve = function (result) {
115
+ (0, instrumentation_2.safeExecuteInTheMiddle)(() => { var _a; return (_a = config === null || config === void 0 ? void 0 : config.responseHook) === null || _a === void 0 ? void 0 : _a.call(config, span, cmd.name, cmd.args, result); }, e => {
116
+ if (e) {
117
+ api_1.diag.error('ioredis instrumentation: response hook failed', e);
118
+ }
119
+ }, true);
120
+ (0, utils_1.endSpan)(span, null);
121
+ origResolve(result);
122
+ };
123
+ const origReject = cmd.reject;
124
+ cmd.reject = function (err) {
125
+ (0, utils_1.endSpan)(span, err);
126
+ origReject(err);
127
+ };
128
+ return result;
129
+ }
130
+ catch (error) {
131
+ (0, utils_1.endSpan)(span, error);
132
+ throw error;
133
+ }
134
+ };
135
+ }
136
+ _traceConnection(original) {
137
+ const instrumentation = this;
138
+ return function () {
139
+ const config = instrumentation.getConfig();
140
+ const hasNoParentSpan = api_1.trace.getSpan(api_1.context.active()) === undefined;
141
+ if ((config === null || config === void 0 ? void 0 : config.requireParentSpan) === true && hasNoParentSpan) {
142
+ return original.apply(this, arguments);
143
+ }
144
+ const span = instrumentation.tracer.startSpan('connect', {
145
+ kind: api_1.SpanKind.CLIENT,
146
+ attributes: {
147
+ [semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.REDIS,
148
+ [semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: 'connect',
149
+ },
150
+ });
151
+ const { host, port } = this.options;
152
+ span.setAttributes({
153
+ [semantic_conventions_1.SemanticAttributes.NET_PEER_NAME]: host,
154
+ [semantic_conventions_1.SemanticAttributes.NET_PEER_PORT]: port,
155
+ [semantic_conventions_1.SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,
156
+ });
157
+ try {
158
+ const client = original.apply(this, arguments);
159
+ (0, utils_1.endSpan)(span, null);
160
+ return client;
161
+ }
162
+ catch (error) {
163
+ (0, utils_1.endSpan)(span, error);
164
+ throw error;
165
+ }
160
166
  };
161
167
  }
162
168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,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;iBACtD;gBACD,IAAI,CAAC,KAAK,CACR,aAAa,CAAC,SAAS,EACvB,aAAa,EACb,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CACtC,CAAC;gBACF,IAAI,IAAA,2BAAS,EAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;oBAC9C,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;iBAClD;gBACD,IAAI,CAAC,KAAK,CACR,aAAa,CAAC,SAAS,EACvB,SAAS,EACT,IAAI,CAAC,gBAAgB,EAAE,CACxB,CAAC;gBACF,OAAO,aAAa,CAAC;YACvB,CAAC,EACD,aAAa,CAAC,EAAE;gBACd,IAAI,aAAa,KAAK,SAAS;oBAAE,OAAO;gBACxC,UAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBACzC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;gBACrD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACnD,CAAC,CACF;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,aAAsB;QAC9C,OAAO,CAAC,QAAkB,EAAE,EAAE;YAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC;IAEO,gBAAgB;QACtB,OAAO,CAAC,QAAkB,EAAE,EAAE;YAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC;CA0HF;AAnLD,wDAmLC","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\nimport { diag, trace, context, SpanKind } from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n} from '@opentelemetry/instrumentation';\nimport { IORedisInstrumentationConfig } from './types';\nimport { IORedisCommand, RedisInterface } from './internal-types';\nimport {\n DbSystemValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport { endSpan } from './utils';\nimport { defaultDbStatementSerializer } from '@opentelemetry/redis-common';\nimport { VERSION } from './version';\n\nconst DEFAULT_CONFIG: IORedisInstrumentationConfig = {\n requireParentSpan: true,\n};\n\nexport class IORedisInstrumentation extends InstrumentationBase<any> {\n constructor(_config: IORedisInstrumentationConfig = {}) {\n super(\n '@opentelemetry/instrumentation-ioredis',\n VERSION,\n Object.assign({}, DEFAULT_CONFIG, _config)\n );\n }\n\n init(): InstrumentationNodeModuleDefinition<any>[] {\n return [\n new InstrumentationNodeModuleDefinition<any>(\n 'ioredis',\n ['>1', '<6'],\n (moduleExports, moduleVersion?: string) => {\n diag.debug('Applying patch for ioredis');\n if (isWrapped(moduleExports.prototype.sendCommand)) {\n this._unwrap(moduleExports.prototype, 'sendCommand');\n }\n this._wrap(\n moduleExports.prototype,\n 'sendCommand',\n this._patchSendCommand(moduleVersion)\n );\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n this._wrap(\n moduleExports.prototype,\n 'connect',\n this._patchConnection()\n );\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports === undefined) return;\n diag.debug('Removing patch for ioredis');\n this._unwrap(moduleExports.prototype, 'sendCommand');\n this._unwrap(moduleExports.prototype, 'connect');\n }\n ),\n ];\n }\n\n /**\n * Patch send command internal to trace requests\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: RedisInterface, cmd?: IORedisCommand) {\n if (arguments.length < 1 || typeof cmd !== 'object') {\n return original.apply(this, arguments);\n }\n const config =\n instrumentation.getConfig() as IORedisInstrumentationConfig;\n const dbStatementSerializer =\n config?.dbStatementSerializer || defaultDbStatementSerializer;\n\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (config?.requireParentSpan === true && hasNoParentSpan) {\n return original.apply(this, arguments);\n }\n\n const span = instrumentation.tracer.startSpan(cmd.name, {\n kind: SpanKind.CLIENT,\n attributes: {\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS,\n [SemanticAttributes.DB_STATEMENT]: dbStatementSerializer(\n cmd.name,\n cmd.args\n ),\n },\n });\n\n if (config?.requestHook) {\n safeExecuteInTheMiddle(\n () =>\n config?.requestHook!(span, {\n moduleVersion,\n cmdName: cmd.name,\n cmdArgs: cmd.args,\n }),\n e => {\n if (e) {\n diag.error('ioredis instrumentation: request hook failed', e);\n }\n },\n true\n );\n }\n\n const { host, port } = this.options;\n\n span.setAttributes({\n [SemanticAttributes.NET_PEER_NAME]: host,\n [SemanticAttributes.NET_PEER_PORT]: port,\n [SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n });\n\n try {\n const result = original.apply(this, arguments);\n\n const origResolve = cmd.resolve;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n cmd.resolve = function (result: any) {\n safeExecuteInTheMiddle(\n () => config?.responseHook?.(span, cmd.name, cmd.args, result),\n e => {\n if (e) {\n diag.error('ioredis instrumentation: response hook failed', e);\n }\n },\n true\n );\n\n endSpan(span, null);\n origResolve(result);\n };\n\n const origReject = cmd.reject;\n cmd.reject = function (err: Error) {\n endSpan(span, err);\n origReject(err);\n };\n\n return result;\n } catch (error: any) {\n endSpan(span, error);\n throw error;\n }\n };\n };\n\n private traceConnection = (original: Function) => {\n const instrumentation = this;\n return function (this: RedisInterface) {\n const config =\n instrumentation.getConfig() as IORedisInstrumentationConfig;\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (config?.requireParentSpan === true && hasNoParentSpan) {\n return original.apply(this, arguments);\n }\n\n const span = instrumentation.tracer.startSpan('connect', {\n kind: SpanKind.CLIENT,\n attributes: {\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS,\n [SemanticAttributes.DB_STATEMENT]: 'connect',\n },\n });\n const { host, port } = this.options;\n\n span.setAttributes({\n [SemanticAttributes.NET_PEER_NAME]: host,\n [SemanticAttributes.NET_PEER_PORT]: port,\n [SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n });\n try {\n const client = original.apply(this, arguments);\n endSpan(span, null);\n return client;\n } catch (error: any) {\n endSpan(span, error);\n throw error;\n }\n };\n };\n}\n"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAoE;AACpE,oEAIwC;AAGxC,8EAG6C;AAC7C,oEAAwE;AACxE,mCAAkC;AAClC,8DAA2E;AAC3E,uCAAoC;AAEpC,MAAM,cAAc,GAAiC;IACnD,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF,MAAa,sBAAuB,SAAQ,qCAAwB;IAClE,YAAY,UAAwC,EAAE;QACpD,KAAK,CACH,wCAAwC,EACxC,iBAAO,EACP,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,CAC3C,CAAC;IACJ,CAAC;IAED,IAAI;QACF,OAAO;YACL,IAAI,qDAAmC,CACrC,SAAS,EACT,CAAC,IAAI,EAAE,IAAI,CA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oBACV,CAAC,yCAAkB,CAAC,SAAS,CAAC,EAAE,qCAAc,CAAC,KAAK;oBACpD,CAAC,yCAAkB,CAAC,YAAY,CAAC,EAAE,SAAS;iBAC7C;aACF,CAAC,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAEpC,IAAI,CAAC,aAAa,CAAC;gBACjB,CAAC,yCAAkB,CAAC,aAAa,CAAC,EAAE,IAAI;gBACxC,CAAC,yCAAkB,CAAC,aAAa,CAAC,EAAE,IAAI;gBACxC,CAAC,yCAAkB,CAAC,oBAAoB,CAAC,EAAE,WAAW,IAAI,IAAI,IAAI,EAAE;aACrE,CAAC,CAAC;YACH,IAAI;gBACF,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAC/C,IAAA,eAAO,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACpB,OAAO,MAAM,CAAC;aACf;YAAC,OAAO,KAAU,EAAE;gBACnB,IAAA,eAAO,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACrB,MAAM,KAAK,CAAC;aACb;QACH,CAAC,CAAC;IACJ,CAAC;CACF;AA3LD,wDA2LC","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\nimport { diag, trace, context, SpanKind } from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n} from '@opentelemetry/instrumentation';\nimport { IORedisInstrumentationConfig } from './types';\nimport { IORedisCommand, RedisInterface } from './internal-types';\nimport {\n DbSystemValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport { endSpan } from './utils';\nimport { defaultDbStatementSerializer } from '@opentelemetry/redis-common';\nimport { VERSION } from './version';\n\nconst DEFAULT_CONFIG: IORedisInstrumentationConfig = {\n requireParentSpan: true,\n};\n\nexport class IORedisInstrumentation extends InstrumentationBase<any> {\n constructor(_config: IORedisInstrumentationConfig = {}) {\n super(\n '@opentelemetry/instrumentation-ioredis',\n VERSION,\n Object.assign({}, DEFAULT_CONFIG, _config)\n );\n }\n\n init(): InstrumentationNodeModuleDefinition<any>[] {\n return [\n new InstrumentationNodeModuleDefinition<any>(\n 'ioredis',\n ['>1', '<6'],\n (module, moduleVersion?: string) => {\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n diag.debug('Applying patch for ioredis');\n if (isWrapped(moduleExports.prototype.sendCommand)) {\n this._unwrap(moduleExports.prototype, 'sendCommand');\n }\n this._wrap(\n moduleExports.prototype,\n 'sendCommand',\n this._patchSendCommand(moduleVersion)\n );\n if (isWrapped(moduleExports.prototype.connect)) {\n this._unwrap(moduleExports.prototype, 'connect');\n }\n this._wrap(\n moduleExports.prototype,\n 'connect',\n this._patchConnection()\n );\n return module;\n },\n module => {\n if (module === undefined) return;\n const moduleExports =\n module[Symbol.toStringTag] === 'Module'\n ? module.default // ESM\n : module; // CommonJS\n diag.debug('Removing patch for ioredis');\n this._unwrap(moduleExports.prototype, 'sendCommand');\n this._unwrap(moduleExports.prototype, 'connect');\n }\n ),\n ];\n }\n\n /**\n * Patch send command internal to trace requests\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: RedisInterface, cmd?: IORedisCommand) {\n if (arguments.length < 1 || typeof cmd !== 'object') {\n return original.apply(this, arguments);\n }\n const config =\n instrumentation.getConfig() as IORedisInstrumentationConfig;\n const dbStatementSerializer =\n config?.dbStatementSerializer || defaultDbStatementSerializer;\n\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (config?.requireParentSpan === true && hasNoParentSpan) {\n return original.apply(this, arguments);\n }\n\n const span = instrumentation.tracer.startSpan(cmd.name, {\n kind: SpanKind.CLIENT,\n attributes: {\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS,\n [SemanticAttributes.DB_STATEMENT]: dbStatementSerializer(\n cmd.name,\n cmd.args\n ),\n },\n });\n\n if (config?.requestHook) {\n safeExecuteInTheMiddle(\n () =>\n config?.requestHook!(span, {\n moduleVersion,\n cmdName: cmd.name,\n cmdArgs: cmd.args,\n }),\n e => {\n if (e) {\n diag.error('ioredis instrumentation: request hook failed', e);\n }\n },\n true\n );\n }\n\n const { host, port } = this.options;\n\n span.setAttributes({\n [SemanticAttributes.NET_PEER_NAME]: host,\n [SemanticAttributes.NET_PEER_PORT]: port,\n [SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n });\n\n try {\n const result = original.apply(this, arguments);\n\n const origResolve = cmd.resolve;\n /* eslint-disable @typescript-eslint/no-explicit-any */\n cmd.resolve = function (result: any) {\n safeExecuteInTheMiddle(\n () => config?.responseHook?.(span, cmd.name, cmd.args, result),\n e => {\n if (e) {\n diag.error('ioredis instrumentation: response hook failed', e);\n }\n },\n true\n );\n\n endSpan(span, null);\n origResolve(result);\n };\n\n const origReject = cmd.reject;\n cmd.reject = function (err: Error) {\n endSpan(span, err);\n origReject(err);\n };\n\n return result;\n } catch (error: any) {\n endSpan(span, error);\n throw error;\n }\n };\n }\n\n private _traceConnection(original: Function) {\n const instrumentation = this;\n return function (this: RedisInterface) {\n const config =\n instrumentation.getConfig() as IORedisInstrumentationConfig;\n const hasNoParentSpan = trace.getSpan(context.active()) === undefined;\n if (config?.requireParentSpan === true && hasNoParentSpan) {\n return original.apply(this, arguments);\n }\n\n const span = instrumentation.tracer.startSpan('connect', {\n kind: SpanKind.CLIENT,\n attributes: {\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.REDIS,\n [SemanticAttributes.DB_STATEMENT]: 'connect',\n },\n });\n const { host, port } = this.options;\n\n span.setAttributes({\n [SemanticAttributes.NET_PEER_NAME]: host,\n [SemanticAttributes.NET_PEER_PORT]: port,\n [SemanticAttributes.DB_CONNECTION_STRING]: `redis://${host}:${port}`,\n });\n try {\n const client = original.apply(this, arguments);\n endSpan(span, null);\n return client;\n } catch (error: any) {\n endSpan(span, error);\n throw error;\n }\n };\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.35.2";
1
+ export declare const VERSION = "0.35.3";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.35.2';
20
+ exports.VERSION = '0.35.3';
21
21
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","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\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.35.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","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\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.35.3';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-ioredis",
3
- "version": "0.35.2",
3
+ "version": "0.35.3",
4
4
  "description": "OpenTelemetry ioredis automatic instrumentation package.",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -38,10 +38,7 @@
38
38
  "files": [
39
39
  "build/src/**/*.js",
40
40
  "build/src/**/*.js.map",
41
- "build/src/**/*.d.ts",
42
- "doc",
43
- "LICENSE",
44
- "README.md"
41
+ "build/src/**/*.d.ts"
45
42
  ],
46
43
  "publishConfig": {
47
44
  "access": "public"
@@ -52,7 +49,7 @@
52
49
  "devDependencies": {
53
50
  "@opentelemetry/api": "^1.3.0",
54
51
  "@opentelemetry/context-async-hooks": "^1.8.0",
55
- "@opentelemetry/contrib-test-utils": "^0.34.2",
52
+ "@opentelemetry/contrib-test-utils": "^0.34.3",
56
53
  "@opentelemetry/sdk-trace-base": "^1.8.0",
57
54
  "@opentelemetry/sdk-trace-node": "^1.8.0",
58
55
  "@types/mocha": "7.0.2",
@@ -69,11 +66,11 @@
69
66
  "typescript": "4.4.4"
70
67
  },
71
68
  "dependencies": {
72
- "@opentelemetry/instrumentation": "^0.44.0",
69
+ "@opentelemetry/instrumentation": "^0.45.1",
73
70
  "@opentelemetry/redis-common": "^0.36.1",
74
71
  "@opentelemetry/semantic-conventions": "^1.0.0",
75
72
  "@types/ioredis4": "npm:@types/ioredis@^4.28.10"
76
73
  },
77
74
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis#readme",
78
- "gitHead": "a8c225d2febcac561a70ca586d3efd5a84f9f3fa"
75
+ "gitHead": "607d375595da3ab51b7f773ac360900121c4361b"
79
76
  }