0.1.0 • Published 7 months ago

@aspecto/opentelemetry-instrumentation-mongodb v0.1.0

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

OpenTelemetry mongodb Instrumentation for Node.js

Gitter chat dependencies devDependencies Apache License

This is a fork of the instrumentation, to add features required by aspecto until they are merged into the main repo and published.

This module provides automatic instrumentation for mongodb.

For automatic instrumentation see the @opentelemetry/sdk-trace-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 { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { MongoDBInstrumentation } = require('@opentelemetry/instrumentation-mongodb');

const provider = new NodeTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

const mongodbInstrumentation = new MongoDBInstrumentation({
  // see under for available configuration
});

Mongo instrumentation Options

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

OptionsTypeDescription
dbStatementSerializerDbStatementSerializerMongodb instrumentation will serialize db.statement using the specified function.
responseHookMongoDbResponseCustomAttributesFunctionHook called before response is returned, which allows to add custom attributes to span.
moduleVersionAttributeNamestringIf passed, a span attribute will be added to all spans with key of the provided moduleVersionAttributeName and value of the patched module version.
requireParentSpanbooleanRequire parent to create mongodb span, default when unset is true
ignoreIsMasterCommandbooleanIf true, a span for periodical isMaster command will not be generated, default when unset is false. The mongodb client library periodically re-run the isMaster command to detect the replica set configuration changes.
aggregateGetMoreOperationsbooleanIf true, a span for a getMore command will not be generated, default when unset is false.
aggregateGetMoreResponseHookMongoDbGetMoreResponseAggregateFunctionHook for aggregate a response payload of a GetMore operation, allows to add custom attributes to span.

Useful links

License

Apache 2.0 - See LICENSE for more information.

0.1.0

7 months ago

0.0.142

8 months ago

0.0.140

1 year ago

0.0.139

1 year ago

0.0.138

2 years ago

0.0.137

2 years ago

0.0.136

2 years ago

0.0.135

2 years ago

0.0.134

2 years ago

0.0.131

2 years ago

0.0.133

2 years ago

0.0.132

2 years ago

0.0.130

2 years ago

0.0.129

3 years ago

0.0.128

3 years ago

0.0.127

3 years ago

0.0.126

3 years ago

0.0.125

3 years ago

0.0.124

3 years ago

0.0.123

3 years ago

0.0.122

3 years ago

0.0.119

3 years ago

0.0.120

3 years ago

0.0.121

3 years ago

0.0.118

3 years ago

0.0.117

3 years ago

0.0.116

3 years ago