Skip to content

Latest commit

 

History

History
 
 

instrumentation-node-cache

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

OpenTelemetry node-cache Instrumentation for Node.js

NPM version

This module provides automatic instrumentation for node-cache.

Supports versions >=5.0.0 of node-cache

Installation

npm install --save opentelemetry-instrumentation-node-cache

Usage

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 Options

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 ❤️