0.43.0 • Published 11 days ago

@opentelemetry/instrumentation-mongodb v0.43.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 days ago

OpenTelemetry MongoDB Instrumentation for Node.js

NPM Published Version Apache License

This module provides automatic instrumentation for the mongodb module, which may be loaded using the @opentelemetry/sdk-trace-node package and is included in the @opentelemetry/auto-instrumentations-node bundle.

If total installation size is not constrained, it is recommended to use the @opentelemetry/auto-instrumentations-node bundle with @opentelemetry/sdk-node for the most seamless instrumentation experience.

Compatible with OpenTelemetry JS API and SDK 1.0+.

Installation

npm install --save @opentelemetry/instrumentation-mongodb

Supported Versions

  • >=3.3 <7

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/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

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

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

See examples/mongodb for a short example.

Mongo instrumentation Options

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

OptionsTypeDescription
enhancedDatabaseReportingstringIf true, additional information about query parameters and results will be attached (as attributes) to spans representing database operations
responseHookMongoDBInstrumentationExecutionResponseHook (function)Function for adding custom attributes from db response
dbStatementSerializerDbStatementSerializer (function)Custom serializer function for the db.statement tag

Semantic Conventions

This package uses @opentelemetry/semantic-conventions version 1.22+, which implements Semantic Convention Version 1.7.0

Attributes collected:

AttributeShort Description
db.systemAn identifier for the database management system (DBMS) product being used.
db.connection_stringThe connection string used to connect to the database.
db.nameThis attribute is used to report the name of the database being accessed.
db.operationThe name of the operation being executed.
db.mongodb.collectionThe collection being accessed within the database stated in db.name.
net.peer.nameRemote hostname or similar.
net.peer.portRemote port number.

Useful links

License

Apache 2.0 - See LICENSE for more information.

0.43.0

11 days ago

0.42.0

1 month ago

0.41.0

2 months ago

0.40.0

2 months ago

0.39.0

3 months ago

0.38.1

4 months ago

0.38.0

5 months ago

0.37.3

6 months ago

0.37.2

6 months ago

0.37.1

7 months ago

0.37.0

8 months ago

0.36.1

9 months ago

0.36.0

10 months ago

0.34.3

12 months ago

0.35.0

11 months ago

0.34.2

1 year ago

0.34.1

1 year ago

0.34.0

1 year ago

0.33.0

1 year ago

0.32.2

2 years ago

0.32.1

2 years ago

0.32.0

2 years ago

0.31.1

2 years ago

0.31.0

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.28.0

2 years ago

0.27.0

2 years ago

0.26.0

3 years ago

0.25.0

3 years ago

0.24.0

3 years ago

0.23.0

3 years ago

0.22.0

3 years ago

0.21.0

3 years ago

0.20.0

3 years ago

0.16.0

3 years ago

0.15.0

3 years ago

0.14.0

3 years ago