@opentelemetry/instrumentation-typeorm
v0.13.0
Published
OpenTelemetry instrumentation for `typeorm` database data-mapper ORM
Readme
OpenTelemetry typeorm Instrumentation for Node.js
This module provides automatic instrumentation for the typeorm package, which may be loaded using the @opentelemetry/instrumentation package.
If total installation size is not constrained, it is recommended to use @opentelemetry/sdk-node for the most seamless instrumentation experience.
Compatible with OpenTelemetry JS API ^1.3.0 and SDK 2.0+.
Installation
npm install --save @opentelemetry/instrumentation-typeormSupported versions
typeormversions>=0.3.0 <1
Usage
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { TypeormInstrumentation } = require('@opentelemetry/instrumentation-typeorm');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const provider = new NodeTracerProvider();
provider.register();
registerInstrumentations({
instrumentations: [
new TypeormInstrumentation({
// see below for available configuration
}),
],
});Instrumentation Options
You can set the following:
| Options | Type | Description |
|-----------------------------------|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| responseHook | TypeormResponseCustomAttributesFunction | Hook called before response is returned, which allows to add custom attributes to span. |
| suppressInternalInstrumentation | boolean | Typeorm uses mongodb/postgres/mysql/mariadb/etc. under the hood. If, for example, postgres instrumentation is enabled, a postgres operation will also create a postgres span describing the communication. Setting the suppressInternalInstrumentation config value to true will cause the instrumentation to suppress instrumentation of underlying operations. |
| enableInternalInstrumentation | boolean | Some methods such as getManyAndCount can generate internally multiple spans. To instrument those set this to true |
| enhancedDatabaseReporting | boolean | set to true if you want to capture the parameter values for parameterized SQL queries (may leak sensitive information) |
Semantic Conventions
Attributes collected:
| Attribute | Short Description |
|----------------------|-----------------------------------------------------------------------------|
| db.namespace | The name of the database being accessed. |
| db.operation.name | The name of the operation being executed (e.g. the SQL keyword). |
| db.collection.name | The name of the table being accessed. |
| 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 address of the database. |
| server.port | Peer port number of the network connection. |
Useful links
- 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
License
Apache 2.0 - See LICENSE for more information.
