Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aspecto/opentelemetry-instrumentation-mongodb

Package Overview
Dependencies
Maintainers
5
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aspecto/opentelemetry-instrumentation-mongodb

Aspecto fork of OpenTelemetry mongodb automatic instrumentation package.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1K
decreased by-0.53%
Maintainers
5
Weekly downloads
 
Created
Source

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.

License

Apache 2.0 - See LICENSE for more information.

Keywords

FAQs

Package last updated on 21 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc