opentelemetry-instrumentation-node-cache
TypeScript icon, indicating that this package has built-in type declarations

0.41.0 • Public • Published

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

Package Sidebar

Install

npm i opentelemetry-instrumentation-node-cache

Weekly Downloads

1,388

Version

0.41.0

License

Apache-2.0

Unpacked Size

64.3 kB

Total Files

18

Last publish

Collaborators

  • aspecto-release-bot