{"name":"@opentelemetry/instrumentation-mongodb","version":"0.54.0","keywords":["mongodb","nodejs","opentelemetry","plugin","profiling","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-mongodb@0.54.0","maintainers":[{"name":"bogdandrutu","email":"bogdandrutu@gmail.com"},{"name":"dyladan","email":"dyladan@gmail.com"},{"name":"pichlermarc","email":"marc.pichler@dynatrace.com"}],"homepage":"https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mongodb#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"48bcad975f1fd17d99e8f6b79f39f1f930ea6837","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-mongodb/download/@opentelemetry/instrumentation-mongodb-0.54.0.tgz","fileCount":18,"integrity":"sha512-xTECmvFNfavpNz7btxmmvkCZKdHphQSSf0J4tSw4OOT0CSTythB/IWo41mYBd6GIutkmeA12dkKPd8zAU7zzyA==","signatures":[{"sig":"MEUCIQCGIDVOTOu24rxVRsWOMYf75Edavq8hbLNo+/i5Ba46YgIgF++uEaxZj/bcItJq7YjDVservAukdrDNgOcFzSsHueo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-mongodb@0.54.0","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":132785,"size":25996,"noattachment":false,"key":"/@opentelemetry/instrumentation-mongodb/-/@opentelemetry/instrumentation-mongodb-0.54.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"393b51596dc869983a03ce8857658029ca122a15","scripts":{"tdd":"npm run test-v5-v6-run -- --watch-extensions ts --watch","lint":"eslint . --ext .ts","test":"npm run test-v4 && npm run test-v5-v6","clean":"rimraf build/*","watch":"tsc -w","compile":"tsc -p .","test-v3":"tav mongodb 3.7.4 npm run test-v3-run","test-v4":"tav mongodb 4.17.0 npm run test-v4-run","lint:fix":"eslint . --ext .ts --fix","prewatch":"npm run precompile","test-v5-v6":"npm run test-v5-v6-run","lint:readme":"node ../../../scripts/lint-readme.js","test-v3-run":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'","test-v4-run":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'","docker:start":"docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=127.0.0.1 -p 27017:27017 --rm mongo","prepublishOnly":"npm run compile","test-v5-v6-run":"nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'","version:update":"node ../../../scripts/version-update.js","test-all-versions":"tav"},"_npmUser":{"name":"dyladan","email":"dyladan@gmail.com"},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git"},"_npmVersion":"lerna/6.6.2/node@v18.20.8+x64 (linux)","description":"OpenTelemetry instrumentation for `mongodb` database client for MongoDB","directories":{},"_nodeVersion":"18.20.8","dependencies":{"@opentelemetry/instrumentation":"^0.201.0","@opentelemetry/semantic-conventions":"^1.27.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","rimraf":"5.0.10","mongodb":"6.15.0","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.47.0","@opentelemetry/context-async-hooks":"^2.0.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-mongodb_0.54.0_1747339579235_0.38824016677310835","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":1747339579442,"_cnpm_publish_time":1747339579442,"dist-tags":{"latest":"0.78.0"}}