@opentelemetry/instrumentation-ioredis 0.40.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/build/src/instrumentation.d.ts +2 -1
- package/build/src/instrumentation.js +13 -13
- package/build/src/instrumentation.js.map +1 -1
- package/build/src/types.d.ts +1 -1
- package/build/src/types.js.map +1 -1
- package/build/src/version.d.ts +2 -1
- package/build/src/version.js +3 -2
- package/build/src/version.js.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-ioredis
|
|
|
17
17
|
|
|
18
18
|
### Supported Versions
|
|
19
19
|
|
|
20
|
-
- `>=2.0.0 <6`
|
|
20
|
+
- [`ioredis`](https://www.npmjs.com/package/ioredis) versions `>=2.0.0 <6`
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
@@ -98,6 +98,20 @@ requestHook: function (
|
|
|
98
98
|
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
## Semantic Conventions
|
|
102
|
+
|
|
103
|
+
This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md)
|
|
104
|
+
|
|
105
|
+
Attributes collected:
|
|
106
|
+
|
|
107
|
+
| Attribute | Short Description |
|
|
108
|
+
|------------------------|-----------------------------------------------------------------------------|
|
|
109
|
+
| `db.connection_string` | The connection string used to connect to the database. |
|
|
110
|
+
| `db.statement` | The database statement being executed. |
|
|
111
|
+
| `db.system` | An identifier for the database management system (DBMS) product being used. |
|
|
112
|
+
| `net.peer.name` | Remote hostname or similar. |
|
|
113
|
+
| `net.peer.port` | Remote port number. |
|
|
114
|
+
|
|
101
115
|
## Useful links
|
|
102
116
|
|
|
103
117
|
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
2
|
import { IORedisInstrumentationConfig } from './types';
|
|
3
3
|
export declare class IORedisInstrumentation extends InstrumentationBase {
|
|
4
|
-
|
|
4
|
+
protected _config: IORedisInstrumentationConfig;
|
|
5
|
+
constructor(config?: IORedisInstrumentationConfig);
|
|
5
6
|
init(): InstrumentationNodeModuleDefinition[];
|
|
6
7
|
/**
|
|
7
8
|
* Patch send command internal to trace requests
|
|
@@ -27,12 +27,12 @@ const DEFAULT_CONFIG = {
|
|
|
27
27
|
requireParentSpan: true,
|
|
28
28
|
};
|
|
29
29
|
class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
30
|
-
constructor(
|
|
31
|
-
super(
|
|
30
|
+
constructor(config = {}) {
|
|
31
|
+
super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, Object.assign({}, DEFAULT_CONFIG, config));
|
|
32
32
|
}
|
|
33
33
|
init() {
|
|
34
34
|
return [
|
|
35
|
-
new instrumentation_1.InstrumentationNodeModuleDefinition('ioredis', ['
|
|
35
|
+
new instrumentation_1.InstrumentationNodeModuleDefinition('ioredis', ['>=2.0.0 <6'], (module, moduleVersion) => {
|
|
36
36
|
const moduleExports = module[Symbol.toStringTag] === 'Module'
|
|
37
37
|
? module.default // ESM
|
|
38
38
|
: module; // CommonJS
|
|
@@ -84,8 +84,8 @@ class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
84
84
|
const span = instrumentation.tracer.startSpan(cmd.name, {
|
|
85
85
|
kind: api_1.SpanKind.CLIENT,
|
|
86
86
|
attributes: {
|
|
87
|
-
[semantic_conventions_1.
|
|
88
|
-
[semantic_conventions_1.
|
|
87
|
+
[semantic_conventions_1.SEMATTRS_DB_SYSTEM]: semantic_conventions_1.DBSYSTEMVALUES_REDIS,
|
|
88
|
+
[semantic_conventions_1.SEMATTRS_DB_STATEMENT]: dbStatementSerializer(cmd.name, cmd.args),
|
|
89
89
|
},
|
|
90
90
|
});
|
|
91
91
|
if (config === null || config === void 0 ? void 0 : config.requestHook) {
|
|
@@ -101,9 +101,9 @@ class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
101
101
|
}
|
|
102
102
|
const { host, port } = this.options;
|
|
103
103
|
span.setAttributes({
|
|
104
|
-
[semantic_conventions_1.
|
|
105
|
-
[semantic_conventions_1.
|
|
106
|
-
[semantic_conventions_1.
|
|
104
|
+
[semantic_conventions_1.SEMATTRS_NET_PEER_NAME]: host,
|
|
105
|
+
[semantic_conventions_1.SEMATTRS_NET_PEER_PORT]: port,
|
|
106
|
+
[semantic_conventions_1.SEMATTRS_DB_CONNECTION_STRING]: `redis://${host}:${port}`,
|
|
107
107
|
});
|
|
108
108
|
try {
|
|
109
109
|
const result = original.apply(this, arguments);
|
|
@@ -142,15 +142,15 @@ class IORedisInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
142
142
|
const span = instrumentation.tracer.startSpan('connect', {
|
|
143
143
|
kind: api_1.SpanKind.CLIENT,
|
|
144
144
|
attributes: {
|
|
145
|
-
[semantic_conventions_1.
|
|
146
|
-
[semantic_conventions_1.
|
|
145
|
+
[semantic_conventions_1.SEMATTRS_DB_SYSTEM]: semantic_conventions_1.DBSYSTEMVALUES_REDIS,
|
|
146
|
+
[semantic_conventions_1.SEMATTRS_DB_STATEMENT]: 'connect',
|
|
147
147
|
},
|
|
148
148
|
});
|
|
149
149
|
const { host, port } = this.options;
|
|
150
150
|
span.setAttributes({
|
|
151
|
-
[semantic_conventions_1.
|
|
152
|
-
[semantic_conventions_1.
|
|
153
|
-
[semantic_conventions_1.
|
|
151
|
+
[semantic_conventions_1.SEMATTRS_NET_PEER_NAME]: host,
|
|
152
|
+
[semantic_conventions_1.SEMATTRS_NET_PEER_PORT]: port,
|
|
153
|
+
[semantic_conventions_1.SEMATTRS_DB_CONNECTION_STRING]: `redis://${host}:${port}`,
|
|
154
154
|
});
|
|
155
155
|
try {
|
|
156
156
|
const client = original.apply(this, arguments);
|
|
@@ -1 +1 @@
|
|
|
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,qCAAmB;IAC7D,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,CAAC,EACZ,CAAC,MAAM,EAAE,aAAsB,EAAE,EAAE;gBACjC,MAAM,aAAa,GACjB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,QAAQ;oBACrC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;oBACvB,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW;gBACzB,IAAI,IAAA,2BAAS,EAAC,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE;oBAClD,IAAI,CAAC,OAAO,CAAC,aAAa,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,E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KAAK,CAAC;aACb;QACH,CAAC,CAAC;IACJ,CAAC;CACF;AAzLD,wDAyLC","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 {\n constructor(_config: IORedisInstrumentationConfig = {}) {\n super(\n '@opentelemetry/instrumentation-ioredis',\n VERSION,\n Object.assign({}, DEFAULT_CONFIG, _config)\n );\n }\n\n init(): InstrumentationNodeModuleDefinition[] {\n return [\n new InstrumentationNodeModuleDefinition(\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 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 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,8EAO6C;AAC7C,oEAAwE;AACxE,mCAAkC;AAClC,8DAA2E;AAC3E,uCAA0D;AAE1D,MAAM,cAAc,GAAiC;IACnD,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF,MAAa,sBAAu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AAC,SAAS,EAAE;gBACvD,IAAI,EAAE,cAAQ,CAAC,MAAM;gBACrB,UAAU,EAAE;oBACV,CAAC,yCAAkB,CAAC,EAAE,2CAAoB;oBAC1C,CAAC,4CAAqB,CAAC,EAAE,SAAS;iBACnC;aACF,CAAC,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAEpC,IAAI,CAAC,aAAa,CAAC;gBACjB,CAAC,6CAAsB,CAAC,EAAE,IAAI;gBAC9B,CAAC,6CAAsB,CAAC,EAAE,IAAI;gBAC9B,CAAC,oDAA6B,CAAC,EAAE,WAAW,IAAI,IAAI,IAAI,EAAE;aAC3D,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;AAxLD,wDAwLC","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_REDIS,\n SEMATTRS_DB_CONNECTION_STRING,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport { safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport { endSpan } from './utils';\nimport { defaultDbStatementSerializer } from '@opentelemetry/redis-common';\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\n\nconst DEFAULT_CONFIG: IORedisInstrumentationConfig = {\n requireParentSpan: true,\n};\n\nexport class IORedisInstrumentation extends InstrumentationBase {\n protected override _config!: IORedisInstrumentationConfig;\n\n constructor(config: IORedisInstrumentationConfig = {}) {\n super(\n PACKAGE_NAME,\n PACKAGE_VERSION,\n Object.assign({}, DEFAULT_CONFIG, config)\n );\n }\n\n init(): InstrumentationNodeModuleDefinition[] {\n return [\n new InstrumentationNodeModuleDefinition(\n 'ioredis',\n ['>=2.0.0 <6'],\n (module, 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(\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 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 [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS,\n [SEMATTRS_DB_STATEMENT]: dbStatementSerializer(cmd.name, cmd.args),\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 [SEMATTRS_NET_PEER_NAME]: host,\n [SEMATTRS_NET_PEER_PORT]: port,\n [SEMATTRS_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 [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_REDIS,\n [SEMATTRS_DB_STATEMENT]: 'connect',\n },\n });\n const { host, port } = this.options;\n\n span.setAttributes({\n [SEMATTRS_NET_PEER_NAME]: host,\n [SEMATTRS_NET_PEER_PORT]: port,\n [SEMATTRS_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"]}
|
package/build/src/types.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface RedisResponseCustomAttributeFunction {
|
|
|
31
31
|
(span: Span, cmdName: string, cmdArgs: CommandArgs, response: unknown): void;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Options available for the IORedis Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/
|
|
34
|
+
* Options available for the IORedis Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-ioredis/README.md#ioredis-instrumentation-options))
|
|
35
35
|
*/
|
|
36
36
|
export interface IORedisInstrumentationConfig extends InstrumentationConfig {
|
|
37
37
|
/** Custom serializer function for the db.statement tag */
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { Span } from '@opentelemetry/api';\n\nexport type CommandArgs = Array<string | Buffer | number | any[]>;\n\n/**\n * Function that can be used to serialize db.statement tag\n * @param cmdName - The name of the command (eg. set, get, mset)\n * @param cmdArgs - Array of arguments passed to the command\n *\n * @returns serialized string that will be used as the db.statement attribute.\n */\nexport type DbStatementSerializer = (\n cmdName: string,\n cmdArgs: CommandArgs\n) => string;\n\nexport interface IORedisRequestHookInformation {\n moduleVersion?: string;\n cmdName: string;\n cmdArgs: CommandArgs;\n}\n\nexport interface RedisRequestCustomAttributeFunction {\n (span: Span, requestInfo: IORedisRequestHookInformation): void;\n}\n\n/**\n * Function that can be used to add custom attributes to span on response from redis server\n * @param span - The span created for the redis command, on which attributes can be set\n * @param cmdName - The name of the command (eg. set, get, mset)\n * @param cmdArgs - Array of arguments passed to the command\n * @param response - The response object which is returned to the user who called this command.\n * Can be used to set custom attributes on the span.\n * The type of the response varies depending on the specific command.\n */\nexport interface RedisResponseCustomAttributeFunction {\n (span: Span, cmdName: string, cmdArgs: CommandArgs, response: unknown): void;\n}\n\n/**\n * Options available for the IORedis Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { Span } from '@opentelemetry/api';\n\nexport type CommandArgs = Array<string | Buffer | number | any[]>;\n\n/**\n * Function that can be used to serialize db.statement tag\n * @param cmdName - The name of the command (eg. set, get, mset)\n * @param cmdArgs - Array of arguments passed to the command\n *\n * @returns serialized string that will be used as the db.statement attribute.\n */\nexport type DbStatementSerializer = (\n cmdName: string,\n cmdArgs: CommandArgs\n) => string;\n\nexport interface IORedisRequestHookInformation {\n moduleVersion?: string;\n cmdName: string;\n cmdArgs: CommandArgs;\n}\n\nexport interface RedisRequestCustomAttributeFunction {\n (span: Span, requestInfo: IORedisRequestHookInformation): void;\n}\n\n/**\n * Function that can be used to add custom attributes to span on response from redis server\n * @param span - The span created for the redis command, on which attributes can be set\n * @param cmdName - The name of the command (eg. set, get, mset)\n * @param cmdArgs - Array of arguments passed to the command\n * @param response - The response object which is returned to the user who called this command.\n * Can be used to set custom attributes on the span.\n * The type of the response varies depending on the specific command.\n */\nexport interface RedisResponseCustomAttributeFunction {\n (span: Span, cmdName: string, cmdArgs: CommandArgs, response: unknown): void;\n}\n\n/**\n * Options available for the IORedis Instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-ioredis/README.md#ioredis-instrumentation-options))\n */\nexport interface IORedisInstrumentationConfig extends InstrumentationConfig {\n /** Custom serializer function for the db.statement tag */\n dbStatementSerializer?: DbStatementSerializer;\n\n /** Function for adding custom attributes on db request */\n requestHook?: RedisRequestCustomAttributeFunction;\n\n /** Function for adding custom attributes on db response */\n responseHook?: RedisResponseCustomAttributeFunction;\n\n /** Require parent to create ioredis span, default when unset is true */\n requireParentSpan?: boolean;\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
package/build/src/version.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
|
|
19
19
|
// this is autogenerated file, see scripts/version-update.js
|
|
20
|
-
exports.
|
|
20
|
+
exports.PACKAGE_VERSION = '0.42.0';
|
|
21
|
+
exports.PACKAGE_NAME = '@opentelemetry/instrumentation-ioredis';
|
|
21
22
|
//# sourceMappingURL=version.js.map
|
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,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 PACKAGE_VERSION = '0.42.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-ioredis';\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-ioredis",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "OpenTelemetry ioredis
|
|
3
|
+
"version": "0.42.0",
|
|
4
|
+
"description": "OpenTelemetry instrumentation for `ioredis` database redis client for Redis",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
7
7
|
"repository": "open-telemetry/opentelemetry-js-contrib",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"clean": "rimraf build/*",
|
|
16
16
|
"lint": "eslint . --ext .ts",
|
|
17
17
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
18
|
+
"lint:readme": "node ../../../scripts/lint-readme.js",
|
|
18
19
|
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/instrumentation-ioredis --include-dependencies",
|
|
19
20
|
"prewatch": "npm run precompile",
|
|
20
21
|
"version:update": "node ../../../scripts/version-update.js",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@opentelemetry/api": "^1.3.0",
|
|
51
52
|
"@opentelemetry/context-async-hooks": "^1.8.0",
|
|
52
|
-
"@opentelemetry/contrib-test-utils": "^0.
|
|
53
|
+
"@opentelemetry/contrib-test-utils": "^0.40.0",
|
|
53
54
|
"@opentelemetry/sdk-trace-base": "^1.8.0",
|
|
54
55
|
"@opentelemetry/sdk-trace-node": "^1.8.0",
|
|
55
56
|
"@types/ioredis4": "npm:@types/ioredis@4.28.10",
|
|
@@ -67,10 +68,10 @@
|
|
|
67
68
|
"typescript": "4.4.4"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"@opentelemetry/instrumentation": "^0.
|
|
71
|
+
"@opentelemetry/instrumentation": "^0.52.0",
|
|
71
72
|
"@opentelemetry/redis-common": "^0.36.2",
|
|
72
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
73
|
+
"@opentelemetry/semantic-conventions": "^1.23.0"
|
|
73
74
|
},
|
|
74
75
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis#readme",
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "ad8436d6a4174f2288cb939080cd4e74da94b0d7"
|
|
76
77
|
}
|