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();
});
Errors
Common errors & fixes
TypeError: trail.use is not a function
Using trail v2+ where API changed; trail no longer has .use() method.
fixDowngrade 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.
fixnpm install trail@1 (peer dependency must be installed)
Connection is not being traced
Connection created before trail.use() or MySQL connection options incompatible.
fixMove 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.
fixnpm install trail-instrument-mysql
Audit
Dependencies
trailrequiredpeer dependency: core tracing framework required
mysqlrequiredpeer dependency: instrumented database driver