{"name":"@opentelemetry/instrumentation-mongodb","version":"0.58.0","keywords":["mongodb","nodejs","opentelemetry","plugin","profiling","tracing"],"author":"OpenTelemetry Authors","license":"Apache-2.0","_id":"@opentelemetry/instrumentation-mongodb@0.58.0","maintainers":[{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-mongodb#readme","dist":{"shasum":"2597087987542d5f49e8ad87a09ba0c150b54021","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-mongodb/download/@opentelemetry/instrumentation-mongodb-0.58.0.tgz","fileCount":18,"integrity":"sha512-h6vrdfCE7qhflgZV41l7vAXUzvbt0ukuHrJ/9ByfNEWiCkNd7tW4FRKdJilWYzr6Nr69ddzMq6vtVFN0WUABUw==","signatures":[{"sig":"MEUCIB+qDedYvoS9HQg0M4JxBVhQpeGR0WinFkIsjzQZewWaAiEAob9WfG1a0As3tHar14Z1N6WDReG5HUkAaIUyrRgXiaA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-mongodb@0.58.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":133333,"size":25988,"noattachment":false,"key":"/@opentelemetry/instrumentation-mongodb/-/@opentelemetry/instrumentation-mongodb-0.58.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"f54a1ba1adf19fd2cbf9ddbdb32a3baca2ed328e","scripts":{"tdd":"npm run test-v5-v6-run -- --watch-extensions ts --watch","lint":"eslint . --ext=ts,js,mjs","test":"npm run test-v5-v6","clean":"rimraf build/*","watch":"tsc -w","compile":"tsc -p .","test-v3":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'","test-v4":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'","lint:fix":"eslint . --ext=ts,js,mjs --fix","test-v5-v6":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'","lint:readme":"node ../../scripts/lint-readme.js","prepublishOnly":"npm run compile","version:update":"node ../../scripts/version-update.js","test-all-versions":"tav","test-services:stop":"cd ../.. && npm run test-services:stop mongodb","test-merge-coverage":"nyc merge .nyc_output coverage/coverage-final.json","test-services:start":"cd ../.. && npm run test-services:start mongodb","test:with-services-env":"cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm test","compile:with-dependencies":"nx run-many -t compile -p @opentelemetry/instrumentation-mongodb","test-all-versions:with-services-env":"cross-env NODE_OPTIONS='-r dotenv/config' DOTENV_CONFIG_PATH=../../test/test-services.env npm run test-all-versions"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git","directory":"packages/instrumentation-mongodb"},"_npmVersion":"lerna/8.2.3/node@v18.20.8+x64 (linux)","description":"OpenTelemetry instrumentation for `mongodb` database client for MongoDB","directories":{},"_nodeVersion":"18.20.8","dependencies":{"@opentelemetry/instrumentation":"^0.205.0","@opentelemetry/semantic-conventions":"^1.27.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","rimraf":"5.0.10","mongodb":"6.19.0","cross-env":"7.0.3","typescript":"5.0.4","@types/bson":"4.0.5","@types/node":"18.18.14","@types/mocha":"10.0.10","test-all-versions":"6.1.0","@opentelemetry/api":"^1.3.0","@opentelemetry/sdk-metrics":"^2.0.0","@opentelemetry/sdk-trace-base":"^2.0.0","@opentelemetry/sdk-trace-node":"^2.0.0","@opentelemetry/contrib-test-utils":"^0.51.0","@opentelemetry/context-async-hooks":"^2.0.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-mongodb_0.58.0_1757520408274_0.6746943908550844","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry MongoDB Instrumentation for Node.js\n\n[![NPM Published Version][npm-img]][npm-url]\n[![Apache License][license-image]][license-image]\n\nThis module provides automatic instrumentation for the [`mongodb`](https://github.com/mongodb/node-mongodb-native) module.\n\nIf total installation size is not constrained, it is recommended to use the [`@opentelemetry/auto-instrumentations-node`](https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node) bundle with [@opentelemetry/sdk-node](https://www.npmjs.com/package/@opentelemetry/sdk-node) for the most seamless instrumentation experience.\n\nCompatible with OpenTelemetry JS API and SDK `1.0+`.\n\n## Installation\n\n```bash\nnpm install --save @opentelemetry/instrumentation-mongodb\n```\n\n### Supported Versions\n\n- [`mongodb`](https://www.npmjs.com/package/mongodb) version `>=3.3.0 <8`\n\n## Usage\n\nOpenTelemetry MongoDB Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems.\n\nTo enable a specific instrumentation, pass it to `registerInstrumentations()`.\nThis is commonly done via `NodeSDK` for fully setting up all OpenTelemetry SDK components:\n\n```js\nconst { NodeSDK } = require('@opentelemetry/sdk-node');\nconst { MongoDBInstrumentation } = require('@opentelemetry/instrumentation-mongodb');\n\nconst sdk = new NodeSDK({\n  instrumentations: [\n    new MongoDBInstrumentation({\n      // see below for available configuration\n    }),\n  ],\n});\nsdk.start();\nprocess.once('beforeExit', async () => { await sdk.shutdown(); });\n```\n\nSee [`examples/mongodb`](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/mongodb) for a short example.\n\n### Mongo instrumentation Options\n\nMongodb instrumentation has few options available to choose from. You can set the following:\n\n| Options                     | Type     | Description |\n| --------------------------- | -------- | ----------- |\n| `enhancedDatabaseReporting` | boolean  | If true, additional information about query parameters and results will be attached (as `attributes`) to spans representing database operations. |\n| `responseHook`              | function | Function for adding custom attributes from db response. See type `MongoDBInstrumentationExecutionResponseHook`. |\n| `dbStatementSerializer`     | function | Custom serializer function for the `db.statement` / `db.query.text` span attribute. See type `DbStatementSerializer`. |\n| `requireParentSpan`         | boolean  | Require a parent span in order to create mongodb spans, default when unset is `true`. |\n\n## Semantic Conventions\n\nThis instrumentation creates spans with database and network attributes following the OpenTelemetry Semantic Conventions.\n\nThe `instrumentation-mongodb` versions 0.73.0 and later emit the stable v1.33.0+ semantic conventions.\n\nSpan attributes:\n\n| Attribute            | Description |\n| -------------------- | ----------- |\n| `db.system.name`     | `'mongodb'` |\n| `db.namespace`       | The MongoDB database name. |\n| `db.operation.name`  | The name of the MongoDB command being executed. |\n| `db.collection.name` | The MongoDB collection being accessed within the database stated in `db.namespace`. |\n| `db.query.text`      | The database query being executed. |\n| `server.address`     | Remote hostname or similar. |\n| `server.port`        | Remote port number. |\n\nMetrics collected:\n\n- [`db.client.connection.count`](https://opentelemetry.io/docs/specs/semconv/database/database-metrics/#metric-dbclientconnectioncount) - The number of connections currently in a given state.\n\n## Useful links\n\n- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>\n- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>\n- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]\n\n## License\n\nApache 2.0 - See [LICENSE][license-url] for more information.\n\n[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions\n[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE\n[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat\n[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-mongodb\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-mongodb.svg\n","publish_time":1757520408456,"_cnpm_publish_time":1757520408456,"dist-tags":{"latest":"0.78.0"}}