Registry / database / trail-instrument-mysql

trail-instrument-mysql

JSON →
library2.4.0jsnpmunverified

MySQL instrumentation plugin for the trail Node.js tracing framework. Current stable version 2.4.0. It wraps mysql connections to automatically trace queries, capturing execution time and metadata. Low release cadence (last release over 5 years ago). Differentiator: minimal configuration, works with any mysql driver that uses the standard callback pattern. Deprecated in favor of OpenTelemetry-based solutions.

npm install trail-instrument-mysql
INSTALL
IMPORT
SIG · TRAIL-INSTRUMENT-M
T
trail-instrument-mysql
databasejavascriptv2.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import TrailInstrumentMySQL from 'trail-instrument-mysql';
const TrailInstrumentMySQL = require('trail-instrument-mysql').default;
ESM default export; CommonJS require works with the default export directly.
TrailInstrumentMySQL
import TrailInstrumentMySQL from 'trail-instrument-mysql';
const { TrailInstrumentMySQL } = require('trail-instrument-mysql');
This package has a single default export, not a named export.
instrument
import Trailmysql from 'trail-instrument-mysql'; import trail from 'trail'; trail.use(Trailmysql);
const { instrument } = require('trail-instrument-mysql');
No named export 'instrument'; use the default exported class with trail.use().

Initializes trail, registers the MySQL instrument, creates a connection, and runs a query to demonstrate auto-tracing.

import trail from 'trail'; import TrailInstrumentMySQL from 'trail-instrument-mysql'; import mysql from 'mysql'; // Register the instrument with trail before creating connections trail.use(TrailInstrumentMySQL); // Create a connection and run a query (connection will be auto-instrumented) const connection = mysql.createConnection({ host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' }); connection.query('SELECT 1 + 1 AS solution', (error, results) => { if (error) throw error; console.log('The solution is:', results[0].solution); connection.end(); });
Debug
Known issues
deprecatedPackage is no longer maintained; no updates since 2019
fix
Migrate to OpenTelemetry instrumentation for MySQL: @opentelemetry/instrumentation-mysql
affects: >=0.0.0
gotchaRequires trail v1.x; incompatible with trail v2+
fix
Use trail v1.x or switch to OpenTelemetry
affects: >=2.0.0
gotchaOnly instruments queries made after trail.use() call; connections created beforehand are not wrapped
fix
Ensure trail.use() is called before any mysql.createConnection() or mysql.createPool()
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: trail.use is not a function
Using trail v2+ where API changed; trail no longer has .use() method.
fix
Downgrade trail to v1.x or use a different instrumentation solution like @opentelemetry/instrumentation-mysql
Cannot find module 'trail'
trail not installed or not in node_modules.
fix
npm install trail@1 (peer dependency must be installed)
Connection is not being traced
Connection created before trail.use() or MySQL connection options incompatible.
fix
Move trail.use() before any connection/pool creation; ensure using callback-based mysql driver
Module not found: Can't resolve 'trail-instrument-mysql'
Package not installed.
fix
npm install trail-instrument-mysql
Upgrade
Version history
2.4.0latest on npm
Audit
Dependencies
trailrequiredpeer dependency: core tracing framework required
mysqlrequiredpeer dependency: instrumented database driver
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
2
Meta
1
Resources
trail-instrument-mysql — npm install trail-instrument-mysql · libregistry