{"name":"@opentelemetry/instrumentation-mysql2","version":"0.59.0","keywords":["instrumentation","mysql","mysql2","nodejs","opentelemetry","profiling","tracing"],"author":{"name":"OpenTelemetry Authors"},"license":"Apache-2.0","_id":"@opentelemetry/instrumentation-mysql2@0.59.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-mysql2#readme","bugs":{"url":"https://github.com/open-telemetry/opentelemetry-js-contrib/issues"},"dist":{"shasum":"938cd4a294b7e4a6e8c3855b8cfe267c8d2e5493","tarball":"http://registry-npm.ywwl.com/@opentelemetry/instrumentation-mysql2/download/@opentelemetry/instrumentation-mysql2-0.59.0.tgz","fileCount":21,"integrity":"sha512-n9/xrVCRBfG9egVbffnlU1uhr+HX0vF4GgtAB/Bvm48wpFgRidqD8msBMiym1kRYzmpWvJqTxNT47u1MkgBEdw==","signatures":[{"sig":"MEQCIHY/eZGKT368C4kWXs6OzmNiXLEUCql/a6caMoLf155hAiAFuqOLWikthPgmv+LyWuvSoRLdlfcPaNQK5od35PtPbg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@opentelemetry%2finstrumentation-mysql2@0.59.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":83760,"size":19917,"noattachment":false,"key":"/@opentelemetry/instrumentation-mysql2/-/@opentelemetry/instrumentation-mysql2-0.59.0.tgz"},"main":"build/src/index.js","types":"build/src/index.d.ts","engines":{"node":"^18.19.0 || >=20.6.0"},"gitHead":"39f08c313dc4d929c110ab7c43771c3cdbf8aa4c","scripts":{"tdd":"npm run test -- --watch-extensions ts --watch","test":"nyc --no-clean mocha 'test/**/*.test.ts'","clean":"rimraf build/*","compile":"tsc -p .","prepublishOnly":"npm run compile","version:update":"node ../../scripts/version-update.js","test-services:ls":"echo mysql","test-all-versions":"tav","test-services:stop":"cd ../.. && npm run test-services:stop mysql","test-services:start":"cd ../.. && npm run test-services:start mysql","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-mysql2","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:e28a8ae3-6a2f-408e-b640-59d4a62bee27"}},"repository":{"url":"git+https://github.com/open-telemetry/opentelemetry-js-contrib.git","type":"git","directory":"packages/instrumentation-mysql2"},"_npmVersion":"lerna/9.0.4/node@v24.14.0+x64 (linux)","description":"OpenTelemetry instrumentation for `mysql2` database client for MySQL","directories":{},"_nodeVersion":"24.14.0","dependencies":{"@opentelemetry/sql-common":"^0.41.2","@opentelemetry/instrumentation":"^0.213.0","@opentelemetry/semantic-conventions":"^1.33.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"mysql2":"3.11.5","@opentelemetry/api":"^1.3.0","@opentelemetry/sdk-trace-base":"^2.0.0","@opentelemetry/contrib-test-utils":"^0.60.0","@opentelemetry/context-async-hooks":"^2.0.0"},"peerDependencies":{"@opentelemetry/api":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/instrumentation-mysql2_0.59.0_1772644303812_0.26119441100346785","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":1772644304013,"_cnpm_publish_time":1772644304013,"dist-tags":{"latest":"0.70.0"}}