This module provides a simple way to initialize multiple Node instrumentations.
Compatible with OpenTelemetry JS API and SDK 1.0+
.
npm install --save @opentelemetry/auto-instrumentations-node
OpenTelemetry Meta Packages for Node automatically loads instrumentations for Node builtin modules and common packages.
Custom configuration for each of the instrumentations can be passed to the function, by providing an object with the name of the instrumentation as a key, and its configuration as the value.
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const exporter = new CollectorTraceExporter();
const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'basic-service',
}),
});
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();
registerInstrumentations({
instrumentations: [
getNodeAutoInstrumentations({
// load custom configuration for http instrumentation
'@opentelemetry/instrumentation-http': {
applyCustomAttributesOnSpan: (span) => {
span.setAttribute('foo2', 'bar2');
},
},
}),
],
});
- @opentelemetry/instrumentation-amqplib
- @opentelemetry/instrumentation-aws-lambda
- @opentelemetry/instrumentation-aws-sdk
- @opentelemetry/instrumentation-bunyan
- @opentelemetry/instrumentation-cassandra-driver
- @opentelemetry/instrumentation-connect
- @opentelemetry/instrumentation-dns
- @opentelemetry/instrumentation-http
- @opentelemetry/instrumentation-grpc
- @opentelemetry/instrumentation-express
- @opentelemetry/instrumentation-koa
- @opentelemetry/instrumentation-lru-memoizer
- @opentelemetry/instrumentation-fastify
- @opentelemetry/instrumentation-generic-pool
- @opentelemetry/instrumentation-graphql
- @opentelemetry/instrumentation-hapi
- @opentelemetry/instrumentation-http
- @opentelemetry/instrumentation-ioredis
- @opentelemetry/instrumentation-redis
- @opentelemetry/instrumentation-pg
- @opentelemetry/instrumentation-knex
- @opentelemetry/instrumentation-koa
- @opentelemetry/instrumentation-memcached
- @opentelemetry/instrumentation-mongodb
- @opentelemetry/instrumentation-mysql2
- @opentelemetry/instrumentation-mysql
- @opentelemetry/instrumentation-nestjs-core
- @opentelemetry/instrumentation-net
- @opentelemetry/instrumentation-pg
- @opentelemetry/instrumentation-pino
- @opentelemetry/instrumentation-redis
- @opentelemetry/instrumentation-restify
- @opentelemetry/instrumentation-winston
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry JavaScript: https://github.com/open-telemetry/opentelemetry-js
APACHE 2.0 - See LICENSE for more information.