Node.js
1. Install
Section titled “1. Install”npm install @opentelemetry/api @opentelemetry/auto-instrumentations-node pino2. Configure
Section titled “2. Configure”Set these where your app runs. Replace YOUR_INGEST_KEY with your key and checkout with your service name.
export OTEL_SERVICE_NAME=checkoutexport OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=productionexport OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.siteqwality.comexport OTEL_EXPORTER_OTLP_HEADERS=Authorization=YOUR_INGEST_KEYexport OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf3. Start your app
Section titled “3. Start your app”node --require @opentelemetry/auto-instrumentations-node/register app.jsIncoming and outgoing HTTP requests, Express, Fastify, database and Redis calls are now traced automatically.
4. Send a log
Section titled “4. Send a log”const logger = require('pino')();
logger.info({ orderId: 42 }, 'order placed');Pino records arrive as logs, linked to the trace of the request that wrote them. Using Winston instead? Also install @opentelemetry/winston-transport.
5. Record a metric (optional)
Section titled “5. Record a metric (optional)”const { metrics } = require('@opentelemetry/api');const orders = metrics.getMeter('checkout').createCounter('orders.placed');
orders.add(1);See your data
Section titled “See your data”Open Logs, Traces or Metrics. New data usually shows up within a minute, and a page that says it is waiting for data switches to your data on its own.
The code on this page comes from a runnable example that is checked against our ingest rules every month.
Nothing arriving? Check that the key is an ingest key for this account, that your account has early access, and the status codes in Ingest routes and limits.