{"name":"@opentelemetry/instrumentation-mongodb","version":"0.55.1","keywords":["mongodb","nodejs","opentelemetry","plugin","profiling","tracing"],"author":"OpenTelemetry Authors","license":"Apache-2.0","_id":"@opentelemetry/instrumentation-mongodb@0.55.1","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","dist":{"shasum":"33bdc42642dde8ac8b18d12b427d784776d5086b","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-mongodb/download/@opentelemetry/instrumentation-mongodb-0.55.1.tgz","fileCount":18,"integrity":"sha512-Wb13YixWm8nB27ZSQW3h070UWkivoh6bjeyDUY6lLimSUulALr+YHBn0t71U1aTcUeaZv3IBNaPRimFXhz6gBA==","signatures":[{"sig":"MEQCIFojjFPXx+Ej7EDG8V+U8dH6DiJhNlhkOfVZZ7NoO5GmAiBPhUCES9n5h30P33xKdPxcqc1PsIvxs757YKi2r2tjDw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-mongodb@0.55.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":132992,"size":25888,"noattachment":false,"key":"/@opentelemetry/instrumentation-mongodb/-/@opentelemetry/instrumentation-mongodb-0.55.1.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"f8ffeb0e47280bd02713719abce6b4e85ecb56e4","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","setup:dev":"nx run-many -t compile -p @opentelemetry/instrumentation-mongodb","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":"open-telemetry/opentelemetry-js-contrib","_npmVersion":"lerna/8.2.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.202.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.48.0","@opentelemetry/context-async-hooks":"^2.0.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-mongodb_0.55.1_1749734117178_0.011742137557702481","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":1749734117365,"_cnpm_publish_time":1749734117365,"dist-tags":{"latest":"0.78.0"}}