{"name":"@opentelemetry/instrumentation-mysql2","version":"0.47.0","keywords":["instrumentation","mysql","mysql2","nodejs","opentelemetry","profiling","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-mysql2@0.47.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-mysql2#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"cd11991b340702caf6cad4a83b01ace7d7b0f903","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-mysql2/download/@opentelemetry/instrumentation-mysql2-0.47.0.tgz","fileCount":18,"integrity":"sha512-rVKuKJ6HFVTNXNo8WuC3lBL/9zQ0OZfga/2dLseg/jlQZzUlWijsA57trnA92pcYxs32HBPSfKpuA88ZAVBFpA==","signatures":[{"sig":"MEUCIEHBXJql6svZ1wf78k1yheec4RKvaNxzjGpPzOBwmpMGAiEA1/KyW1Zjauq4SqYx7/ho/yWczpZijQpaDTdl8uyZ6/0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-mysql2@0.47.0","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":60776,"size":14803,"noattachment":false,"key":"/@opentelemetry/instrumentation-mysql2/-/@opentelemetry/instrumentation-mysql2-0.47.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 -- --watch-extensions ts --watch","lint":"eslint . --ext .ts","test":"nyc mocha 'test/**/*.test.ts'","clean":"rimraf build/*","compile":"tsc -p .","lint:fix":"eslint . --ext .ts --fix","prewatch":"npm run precompile","prepublishOnly":"npm run compile","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 `mysql2` database client for MySQL","directories":{},"_nodeVersion":"18.20.8","dependencies":{"@opentelemetry/sql-common":"^0.41.0","@opentelemetry/instrumentation":"^0.201.0","@opentelemetry/semantic-conventions":"^1.27.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","mysql2":"3.11.5","rimraf":"5.0.10","semver":"7.7.1","typescript":"5.0.4","@types/node":"18.18.14","@types/mocha":"10.0.10","@types/semver":"7.5.8","test-all-versions":"6.1.0","@opentelemetry/api":"^1.3.0","@opentelemetry/sdk-trace-base":"^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-mysql2_0.47.0_1747339581243_0.8425422653789452","host":"s3://npm-registry-packages-npm-production"},"readme":"# OpenTelemetry mysql 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 [`mysql2`](https://github.com/sidorares/node-mysql2) 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-mysql2\n```\n\n## Supported Versions\n\n- [`mysql2`](https://www.npmjs.com/package/mysql2) versions `>=1.4.2 <4`\n\n## Usage\n\nOpenTelemetry MySQL2 Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [mysql2](https://github.com/sidorares/node-mysql2).\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 { MySQL2Instrumentation } = require('@opentelemetry/instrumentation-mysql2');\n\nconst sdk = new NodeSDK({\n  instrumentations: [\n    new MySQL2Instrumentation(),\n  ],\n});\nsdk.start();\nprocess.once('beforeExit', async () => { await sdk.shutdown(); });\n```\n\n### MySQL2 Instrumentation Options\n\nYou can set the following instrumentation options:\n\n| Options                           | Type                                                    | Description                                                                                                                                                                                                                                                                                                                  |\n|-----------------------------------|---------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `responseHook`                    | `MySQL2InstrumentationExecutionResponseHook` (function) | Function for adding custom attributes from db response                                                                                                                                                                                                                                                                       |\n| `addSqlCommenterCommentToQueries` | `boolean`                                               | If true, adds [sqlcommenter](https://github.com/open-telemetry/opentelemetry-sqlcommenter) specification compliant comment to queries with tracing context (default false). _NOTE: A comment will not be added to queries that already contain `--` or `/* ... */` in them, even if these are not actually part of comments_ |\n| `maskStatement`                   | `boolean`                                               | If true, masks the `db.statement` attribute in spans (default false) with the `maskStatementHook`                                                                                                                                                                                                                            |\n| `maskStatementHook`               | `MySQL2InstrumentationMaskStatementHook` (function)     | Function for masking the `db.statement` attribute in spans  Default: `return query.replace(/\\b\\d+\\b/g, '?').replac(/([\"'])(?:(?=(\\\\?))\\2.)*?\\1/g, '?');`                                                                                                                                                                     |\n\n\n## Semantic Conventions\n\nThe `@opentelemetry/instrumentation-mysql2` versions 0.66.0 and later emit the stable v1.33.0+ semantic conventions.\n\n| Attribute         | Description                                                                   |\n|-------------------|-------------------------------------------------------------------------------|\n| `db.system.name`  | The database system. Always `'mysql'`.                                        |\n| `db.query.text`   | The database query being executed.                                            |\n| `db.namespace`    | The name of the database, fully qualified within the server address and port. |\n| `server.address`  | Remote hostname or similar.                                                   |\n| `server.port`     | Remote port number.                                                           |\n\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-mysql2\n[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-mysql2.svg\n","publish_time":1747339581398,"_cnpm_publish_time":1747339581398,"dist-tags":{"latest":"0.70.0"}}