0.40.0 • Published 7 months ago

opentelemetry-instrumentation-node-cache v0.40.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

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:

OptionTypeDescription
requestHookfunctionHook for adding custom attributes before express start handling the request. Receives params: span, { moduleVersion, operation, args }
responseHookfunctionHook called before response is returned, which allows to add custom attributes to span.Function receive params: span, { operation, response }
requireParentSpanbooleanSet 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 ❤️