@sumologic/opentelemetry-node
v1.1.0
Published
Adds OpenTelemetry tracing auto-instrumentation for Node.js
Downloads
57
Readme
Sumo Logic OpenTelemetry Node
An all-in-one runner for node.js projects used to enable OpenTelemetry auto-instrumentation.
It contains all supported detectors, propagators and auto-instrumentation plugins.
Usage
Instead of running your script like node index.js
, do npx @sumologic/opentelemetry-node index.js
.
Your index.js
file will run automatically with a started @opentelemetry/sdk-node
.
Remember to provide configuration using environment variables:
OTEL_EXPORTER_OTLP_ENDPOINT
- source URL of your traces collectorOTEL_SERVICE_NAME
- a logical service name that represents its business logicOTEL_RESOURCE_ATTRIBUTES
- extra attributes attached to all spans
e.g. OTEL_SERVICE_NAME=api OTEL_RESOURCE_ATTRIBUTES="application=default,deployment=test" OTEL_EXPORTER_OTLP_ENDPOINT=https://... npx @sumologic/opentelemetry-node index.js
.
To speed up npx @sumologic/opentelemetry-node
command, you can do npm i -g @sumologic/opentelemetry-node
.
Instrumented packages
This package enables all officially supported core and contrib auto-instrumentation plugins defined in @opentelemetry/auto-instrumentations-node, that is:
- opentelemetry/instrumentation-amqplib
- opentelemetry/instrumentation-aws-lambda
- opentelemetry/instrumentation-aws-sdk
- opentelemetry/instrumentation-bunyan
- [opentelemetry/instrumentation-cassandra-driver](https://www.npmjs.com/package/@opentelemetry/instrumentation-cassandra-driver
- opentelemetry/instrumentation-connect
- [opentelemetry/instrumentation-cucumber](https://www.npmjs.com/package/@opentelemetry/instrumentation-cucumber
- opentelemetry/instrumentation-dataloader
- opentelemetry/instrumentation-dns
- opentelemetry/instrumentation-express
- opentelemetry/instrumentation-fastify
- opentelemetry/instrumentation-fs
- opentelemetry/instrumentation-generic-pool
- opentelemetry/instrumentation-graphql
- opentelemetry/instrumentation-grpc
- opentelemetry/instrumentation-hapi
- opentelemetry/instrumentation-http
- opentelemetry/instrumentation-ioredis
- opentelemetry/instrumentation-knex
- opentelemetry/instrumentation-koa
- opentelemetry/instrumentation-lru-memoizer
- opentelemetry/instrumentation-memcached
- opentelemetry/instrumentation-mongodb
- opentelemetry/instrumentation-mongoose
- opentelemetry/instrumentation-mysql
- opentelemetry/instrumentation-mysql2
- opentelemetry/instrumentation-nestjs-core
- opentelemetry/instrumentation-net
- opentelemetry/instrumentation-pg
- opentelemetry/instrumentation-pino
- opentelemetry/instrumentation-redis
- opentelemetry/instrumentation-redis-4
- opentelemetry/instrumentation-restify
- opentelemetry/instrumentation-router
- opentelemetry/instrumentation-socket.io
- opentelemetry/instrumentation-tedious
- opentelemetry/instrumentation-undici
- opentelemetry/instrumentation-winston
Manual instrumentation
In order to create spans manually, install @opentelemetry/api
package: npm i @opentelemetry/api@^1.9.0
.
Example:
const opentelemetry = require('@opentelemetry/api');
const tracer = opentelemetry.trace.getTracer('default');
const span = tracer.startSpan('operation');
span.end();