Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 3.41 KB

File metadata and controls

73 lines (52 loc) · 3.41 KB

OpenTelemetry mongodb Instrumentation for Node.js

NPM Published Version dependencies devDependencies Apache License

This module provides automatic instrumentation for mongodb.

For automatic instrumentation see the @opentelemetry/node package.

Installation

npm install --save @opentelemetry/instrumentation-mongodb

Supported Versions

  • '>=3.3 <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 instrumentation (mongodb in this case), specify it in the Node Tracer's configuration.

const { MongoDBInstrumentation } = require('@opentelemetry/instrumentation-mongodb');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
provider.register();

registerInstrumentations({
  instrumentations: [
    new MongoDBInstrumentation({
      // see under for available configuration
    }),
  ],
});

Mongo instrumentation Options

Mongodb instrumentation has few options available to choose from. You can set the following:

Options Type Description
enhancedDatabaseReporting string If true, additional information about query parameters and results will be attached (as attributes) to spans representing database operations
responseHook MongoDBInstrumentationExecutionResponseHook (function) Function for adding custom attributes from db response

Useful links

License

Apache 2.0 - See LICENSE for more information.