This module provides automatic instrumentation for the mysql module.
If total installation size is not constrained, it is recommended to use the @opentelemetry/auto-instrumentations-node bundle with @opentelemetry/sdk-node for the most seamless instrumentation experience.
Compatible with OpenTelemetry JS API and SDK 1.0+.
npm install --save @opentelemetry/instrumentation-mysqlmysqlversions>=2.0.0 <3
OpenTelemetry MySQL 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 mysql.
To enable a specific instrumentation, pass it to registerInstrumentations().
This is commonly done via NodeSDK for fully setting up all OpenTelemetry SDK components:
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { MySQLInstrumentation } = require('@opentelemetry/instrumentation-mysql');
const sdk = new NodeSDK({
instrumentations: [
new MySQLInstrumentation(),
],
});
sdk.start();
process.once('beforeExit', async () => { await sdk.shutdown(); });See examples/mysql for a short example.
| Options | Type | Default | Description |
|---|---|---|---|
enhancedDatabaseReporting |
boolean |
false |
If true, a db.mysql.values attribute containing the query's parameters will be add to database spans. Note that this is not an attribute defined in Semantic Conventions. |
The instrumentation-mysql versions 0.66.0 and later emit the stable v1.33.0+ semantic conventions.
Attributes collected:
| Attribute | Description |
|---|---|
db.system.name |
The database system. Always 'mysql'. |
db.namespace |
The database associated with the connection, as provided at connection time. (This does not track changes made via SELECT DATABASE().) |
db.query.text |
The database query being executed. |
server.address |
Remote hostname or similar. |
server.port |
Remote port number. |
Metrics collected:
db.client.connections.usage- The number of connections currently in a given state.
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
- For help or feedback on this project, join us in GitHub Discussions
Apache 2.0 - See LICENSE for more information.