{"name":"@opentelemetry/instrumentation-mongodb","version":"0.71.0","keywords":["mongodb","nodejs","opentelemetry","plugin","profiling","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-mongodb@0.71.0","maintainers":[{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"},{"name":"overbalance","email":"overbalancedev@proton.me"},{"name":"npmjs-account","email":"npmjs-account@opentelemetry.io"},{"name":"trentm","email":"trentm@gmail.com"},{"name":"martinkuba","email":"martin@martinkuba.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-mongodb#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"d011393ccb0d049fc13a13caa82e3ffc79e1652e","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-mongodb/download/@opentelemetry/instrumentation-mongodb-0.71.0.tgz","fileCount":21,"integrity":"sha512-6rwfVjAUY69CKkyGqzL+F5X7Nzw0+Ke9pOxk9xUPJpy8vracZxuQYF7rWu02sV1xOgi4u52449SuVhD+zaSiIA==","signatures":[{"sig":"MEUCIHVfR2vEhtpRhTvXyUQpEFI2NzJjAkP5JzR+VloRmIf3AiEApey4gFMNhK9f41UDqkSOP9giImnTz4wNzoXxPdRPsks=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-mongodb@0.71.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":151899,"size":29426,"noattachment":false,"key":"/@opentelemetry/instrumentation-mongodb/-/@opentelemetry/instrumentation-mongodb-0.71.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"15ef7506553f631ea4181391e0c5725a56f0d082","scripts":{"test":"npm run test-v6 && npm run test-unit","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-metrics-v4plus.test.ts test/mongodb-v4.test.ts","test-v5":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' test/mongodb-metrics-v4plus.test.ts test/mongodb-v5plus.test.ts","test-v6":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' test/mongodb-metrics-v4plus.test.ts test/mongodb-v5plus.test.ts","test-v7":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' test/mongodb-metrics-v4plus.test.ts test/mongodb-v5plus.test.ts","test-unit":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' test/unit/*.test.ts","lint:readme":"node ../../scripts/lint-readme.js","prepublishOnly":"npm run compile","version:update":"node ../../scripts/version-update.js","test-services:ls":"echo mongodb","test-all-versions":"tav","test-services:stop":"cd ../.. && npm run test-services:stop mongodb","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":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:64e21fd0-e7a5-4a02-9bf7-c9bae07c2f11"}},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git","directory":"packages/instrumentation-mongodb"},"_npmVersion":"lerna/9.0.7/node@v24.14.1+x64 (linux)","description":"OpenTelemetry instrumentation for `mongodb` database client for MongoDB","directories":{},"_nodeVersion":"24.14.1","dependencies":{"@opentelemetry/instrumentation":"^0.218.0","@opentelemetry/semantic-conventions":"^1.33.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"mongodb":"6.19.0","@types/bson":"4.0.5","@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.65.0","@opentelemetry/context-async-hooks":"^2.0.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-mongodb_0.71.0_1778668278082_0.21381709804928573","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":1778668278216,"_cnpm_publish_time":1778668278216,"dist-tags":{"latest":"0.78.0"}}