OpenTelemetry instrumentation for `typeorm` database data-mapper ORM
npm install @opentelemetry/instrumentation-typeormtypeorm Instrumentation for Node.js[![NPM Published Version][npm-img]][npm-url]
[![Apache License][license-image]][license-image]
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 https://www.npmjs.com/package/@opentelemetry/sdk-node" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">@opentelemetry/sdk-node for the most seamless instrumentation experience.
Compatible with OpenTelemetry JS API ^1.3.0 and SDK 2.0+.
``bash`
npm install --save @opentelemetry/instrumentation-typeorm
- typeorm versions >=0.3.0 <1
`js
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
}),
],
});
`
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) |
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. |
|
- For more information on OpenTelemetry, visit:
- For more about OpenTelemetry JavaScript:
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
Apache 2.0 - See [LICENSE][license-url] for more information.
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-typeorm
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-typeorm.svg