This module provides automatic instrumentation for the knex module. This module allows the user to automatically collect trace data and export them to their backend of choice.
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-knexknexversions>=0.10.0 <4
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { KnexInstrumentation } = require('@opentelemetry/instrumentation-knex');
const sdk = new NodeSDK({
instrumentations: [
new KnexInstrumentation({
// See below for configuration options.
}),
],
});
sdk.start();
process.once('beforeExit', async () => { await sdk.shutdown(); });| Options | Type | Example | Description |
|---|---|---|---|
maxQueryLength |
number |
100 |
Truncate db.query.text attribute to a maximum length. If the statement is truncated '..' is added to its end. Default 1022. -1 leaves db.query.text untouched. |
requireParentSpan |
boolean |
false |
Don't create spans unless they are part of an existing trace. Default is false. |
This instrumentation creates spans with database-related attributes.
The instrumentation-knex versions 0.64.0 and later emit the stable v1.33.0+ semantic conventions.
| Attribute | Short Description |
|---|---|
db.collection.name |
The name of the primary table that the operation is acting upon. |
db.namespace |
The name of the database being accessed. |
db.operation.name |
The name of the operation being executed. |
db.query.text |
The database statement being executed. |
db.system.name |
An identifier for the database management system (DBMS) product being used. |
server.address |
Remote hostname or similar. |
server.port |
Remote port number. |
- 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.