This module provides automatic instrumentation for node-cache
.
Supports versions >=5.0.0 of node-cache
npm install --save opentelemetry-instrumentation-node-cache
For further automatic instrumentation instruction see the @opentelemetry/instrumentation package.
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { NodeCacheInstrumentation } = require('opentelemetry-instrumentation-node-cache');
registerInstrumentations({
tracerProvider,
instrumentations: [
new NodeCacheInstrumentation({
// see under for available configuration
})
]
});
node-cache instrumentation has few options available to choose from. You can set the following:
Option | Type | Description |
---|---|---|
requestHook |
function | Hook for adding custom attributes before express start handling the request. Receives params: span, { moduleVersion, operation, args } |
responseHook |
function | Hook called before response is returned, which allows to add custom attributes to span. Function receive params: span, { operation, response } |
requireParentSpan |
boolean |
Set to true if you only want to trace operation which has parent spans |
See the tests for config usage example.
This extension (and many others) was developed by Aspecto with ❤️