opentelemetry-js/packages/opentelemetry-plugin-mongodb/README.md

2.9 KiB

OpenTelemetry mongodb Instrumentation for Node.js

Gitter chat dependencies devDependencies Apache License

This module provides automatic instrumentation for mongodb.

For automatic instrumentation see the @opentelemetry/node package.

Installation

npm install --save @opentelemetry/plugin-mongodb

Supported Versions

  • '>=2.0.0 <4

Usage

OpenTelemetry Mongodb Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems.

To load a specific plugin (mongodb in this case), specify it in the Node Tracer's configuration.

const { NodeTracerRegistry } = require('@opentelemetry/node');

const registry = new NodeTracerRegistry({
  plugins: {
    mongodb: {
      enabled: true,
      // You may use a package name or absolute path to the file.
      path: '@opentelemetry/plugin-mongodb',
    }
  }
});

To load all the supported plugins, use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules.

const { NodeTracerRegistry } = require('@opentelemetry/node');

const registry = new NodeTracerRegistry();

See examples/mongodb for a short example.

License

Apache 2.0 - See LICENSE for more information.