Node
<!-- status: ga language: node -->
Node.js: zero-code instrumentation
@opentelemetry/auto-instrumentations-node registers instrumentations for http, express, fastify, pg, mysql, redis, grpc and more before your code loads, with no code change. Nothing Watchtower-specific is installed: it reads the standard OTEL_* variables.
Create a project, then an ingestion key (
wti_...) with theingest:tracesscope. The key is shown once.Point the instrumentation at the gateway and pass the key in the
x-watchtower-keyheader:
export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.example.com
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS=x-watchtower-key=wti_YOUR_KEY
export OTEL_SERVICE_NAME=my-serviceInstall the package and preload it:
npm install @opentelemetry/auto-instrumentations-node
node --require @opentelemetry/auto-instrumentations-node/register app.jsFor containers set NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register" instead of editing the command line.
Send one request to the service, then open the project's onboarding screen: it turns green when the first span arrives.