Skip to content

Node.js

Terminal window
npm install @opentelemetry/api @opentelemetry/auto-instrumentations-node pino

Set these where your app runs. Replace YOUR_INGEST_KEY with your key and checkout with your service name.

Terminal window
export OTEL_SERVICE_NAME=checkout
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=production
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.siteqwality.com
export OTEL_EXPORTER_OTLP_HEADERS=Authorization=YOUR_INGEST_KEY
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
Terminal window
node --require @opentelemetry/auto-instrumentations-node/register app.js

Incoming and outgoing HTTP requests, Express, Fastify, database and Redis calls are now traced automatically.

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.

const { metrics } = require('@opentelemetry/api');
const orders = metrics.getMeter('checkout').createCounter('orders.placed');
orders.add(1);

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.