@opentelemetry/plugin-ioredis
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -29,1 +29,2 @@ /*! | ||
} | ||
//# sourceMappingURL=enums.d.ts.map |
@@ -17,1 +17,2 @@ /*! | ||
export * from './ioredis'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -18,2 +18,3 @@ /*! | ||
import * as ioredisTypes from 'ioredis'; | ||
import { IORedisPluginConfig } from './types'; | ||
export declare class IORedisPlugin extends BasePlugin<typeof ioredisTypes> { | ||
@@ -24,2 +25,3 @@ readonly moduleName: string; | ||
readonly supportedVersions: string[]; | ||
protected _config: IORedisPluginConfig; | ||
constructor(moduleName: string); | ||
@@ -35,1 +37,2 @@ protected patch(): typeof ioredisTypes; | ||
export declare const plugin: IORedisPlugin; | ||
//# sourceMappingURL=ioredis.d.ts.map |
@@ -47,3 +47,3 @@ "use strict"; | ||
return (original) => { | ||
return utils_1.traceSendCommand(tracer, original); | ||
return utils_1.traceSendCommand(tracer, original, exports.plugin._config); | ||
}; | ||
@@ -50,0 +50,0 @@ } |
@@ -18,2 +18,3 @@ /*! | ||
import * as ioredisTypes from 'ioredis'; | ||
import { PluginConfig } from '@opentelemetry/api'; | ||
export interface IORedisCommand { | ||
@@ -30,1 +31,17 @@ reject: (err: Error) => void; | ||
} | ||
/** | ||
* Function that can be used to serialize db.statement tag | ||
* @param cmdName - The name of the command (eg. set, get, mset) | ||
* @param cmdArgs - Array of arguments passed to the command | ||
* | ||
* @returns serialized string that will be used as the db.statement attribute. | ||
*/ | ||
export declare type DbStatementSerializer = (cmdName: IORedisCommand['name'], cmdArgs: IORedisCommand['args']) => string; | ||
/** | ||
* Options available for the IORedis Plugin (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-ioredis#ioredis-plugin-options)) | ||
*/ | ||
export interface IORedisPluginConfig extends PluginConfig { | ||
/** Custom serializer function for the db.statement tag */ | ||
dbStatementSerializer?: DbStatementSerializer; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -18,4 +18,5 @@ /*! | ||
import { Tracer } from '@opentelemetry/api'; | ||
import { IORedisPluginClientTypes, IORedisCommand } from './types'; | ||
import { IORedisPluginClientTypes, IORedisCommand, IORedisPluginConfig } from './types'; | ||
export declare const traceConnection: (tracer: Tracer, original: Function) => (this: ioredisTypes.Redis & IORedisPluginClientTypes) => any; | ||
export declare const traceSendCommand: (tracer: Tracer, original: Function) => (this: ioredisTypes.Redis & IORedisPluginClientTypes, cmd?: IORedisCommand | undefined) => any; | ||
export declare const traceSendCommand: (tracer: Tracer, original: Function, config?: IORedisPluginConfig | undefined) => (this: ioredisTypes.Redis & IORedisPluginClientTypes, cmd?: IORedisCommand | undefined) => any; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -60,3 +60,8 @@ "use strict"; | ||
}; | ||
exports.traceSendCommand = (tracer, original) => { | ||
const defaultDbStatementSerializer = (cmdName, cmdArgs) => Array.isArray(cmdArgs) && cmdArgs.length | ||
? `${cmdName} ${cmdArgs.join(' ')}` | ||
: cmdName; | ||
exports.traceSendCommand = (tracer, original, config) => { | ||
var _a; | ||
const dbStatementSerializer = ((_a = config) === null || _a === void 0 ? void 0 : _a.dbStatementSerializer) || defaultDbStatementSerializer; | ||
return function (cmd) { | ||
@@ -69,5 +74,3 @@ if (arguments.length >= 1 && typeof cmd === 'object') { | ||
[enums_1.AttributeNames.DB_TYPE]: ioredis_1.IORedisPlugin.DB_TYPE, | ||
[enums_1.AttributeNames.DB_STATEMENT]: Array.isArray(cmd.args) && cmd.args.length | ||
? `${cmd.name} ${cmd.args.join(' ')}` | ||
: cmd.name, | ||
[enums_1.AttributeNames.DB_STATEMENT]: dbStatementSerializer(cmd.name, cmd.args), | ||
}, | ||
@@ -74,0 +77,0 @@ }); |
@@ -16,2 +16,3 @@ /*! | ||
*/ | ||
export declare const VERSION = "0.7.0"; | ||
export declare const VERSION = "0.8.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -19,3 +19,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.7.0'; | ||
exports.VERSION = '0.8.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/plugin-ioredis", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "OpenTelemetry ioredis automatic instrumentation package.", | ||
@@ -47,6 +47,6 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@opentelemetry/context-async-hooks": "^0.6.1", | ||
"@opentelemetry/node": "^0.6.1", | ||
"@opentelemetry/test-utils": "^0.7.0", | ||
"@opentelemetry/tracing": "^0.6.1", | ||
"@opentelemetry/context-async-hooks": "^0.8.3", | ||
"@opentelemetry/node": "^0.8.3", | ||
"@opentelemetry/test-utils": "^0.8.0", | ||
"@opentelemetry/tracing": "^0.8.3", | ||
"@types/ioredis": "^4.14.3", | ||
@@ -60,6 +60,6 @@ "@types/mocha": "^7.0.0", | ||
"ioredis": "^4.14.1", | ||
"mocha": "^6.2.2", | ||
"mocha": "^7.1.2", | ||
"nyc": "^15.0.0", | ||
"rimraf": "^3.0.0", | ||
"ts-mocha": "^6.0.0", | ||
"ts-mocha": "^7.0.0", | ||
"ts-node": "^8.5.4", | ||
@@ -71,6 +71,6 @@ "tslint-consistent-codestyle": "^1.16.0", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.6.1", | ||
"@opentelemetry/core": "^0.6.1", | ||
"@opentelemetry/api": "^0.8.3", | ||
"@opentelemetry/core": "^0.8.3", | ||
"shimmer": "^1.2.1" | ||
} | ||
} |
@@ -45,2 +45,34 @@ # OpenTelemetry ioredis Instrumentation for Node.js | ||
### IORedis Plugin Options | ||
IORedis plugin has few options available to choose from. You can set the following: | ||
| Options | Type | Description | | ||
| ------- | ---- | ----------- | | ||
| `dbStatementSerializer` | `DbStatementSerializer` | IORedis plugin will serialize db.statement using the specified function. | | ||
#### Custom db.statement Serializer | ||
The plugin serializes the whole command into a Span attribute called `db.statement`. The standard serialization format is `{cmdName} {cmdArgs.join(',')}`. | ||
It is also possible to define a custom serialization function. The function will receive the command name and arguments and must return a string. | ||
Here is a simple example to serialize the command name skipping arguments: | ||
```javascript | ||
const { NodeTracerProvider } = require('@opentelemetry/node'); | ||
const provider = new NodeTracerProvider({ | ||
plugins: { | ||
ioredis: { | ||
enabled: true, | ||
// You may use a package name or absolute path to the file. | ||
path: '@opentelemetry/plugin-ioredis', | ||
dbStatementSerializer: function (cmdName, cmdArgs) { | ||
return cmdName; | ||
} | ||
} | ||
} | ||
}); | ||
``` | ||
## Useful links | ||
@@ -47,0 +79,0 @@ - For more information on OpenTelemetry, visit: <https://opentelemetry.io/> |
33928
403
94
+ Added@opentelemetry/api@0.8.3(transitive)
+ Added@opentelemetry/context-base@0.8.3(transitive)
+ Added@opentelemetry/core@0.8.3(transitive)
- Removed@opentelemetry/api@0.6.1(transitive)
- Removed@opentelemetry/context-base@0.6.1(transitive)
- Removed@opentelemetry/core@0.6.1(transitive)
Updated@opentelemetry/api@^0.8.3
Updated@opentelemetry/core@^0.8.3