Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

OpenTelemetry MySQL Instrumentation for Node.js

NPM Published Version Apache License

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+.

Installation

npm install --save @opentelemetry/instrumentation-mysql

Supported Versions

  • mysql versions >=2.0.0 <3

Usage

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.

MySQL instrumentation Options

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.

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:

Useful links

License

Apache 2.0 - See LICENSE for more information.