Trace a Node.js app
The official OpenTelemetry auto-instrumentations for Node.js hook HTTP, Express, Fastify, gRPC, Postgres, Redis and more. No application code changes are needed. Epok accepts OTLP over HTTP, so keep the HTTP exporter; there is no gRPC endpoint.
Time to first span: about 5 min. API key: app.epok.cloud, then Settings, then API Keys.
1. Set the OTLP endpoint and key
Set these in the environment that starts your app. Use the base URL; the SDK appends /v1/traces. The header name must be x-api-key.
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.epok.cloud"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf" # not gRPC
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=YOUR_API_KEY"
export OTEL_EXPORTER_OTLP_COMPRESSION="gzip"
export OTEL_SERVICE_NAME="checkout-service" # becomes service.name2. Install the auto-instrumentation
Install the official package and start Node with its register hook. The hook loads before your application code and initializes the SDK.
npm install @opentelemetry/api @opentelemetry/auto-instrumentations-node
# Start Node with the register hook. It sets up the SDK for you.
node --require @opentelemetry/auto-instrumentations-node/register app.js3. Set service.name
OTEL_SERVICE_NAME becomes the service.name resource attribute. Use one stable name per service. This is the name you filter by in Epok.
4. Verify traces in Epok
- Send a request through your app.
- Open Traces in the app and filter by service name
checkout-service. - A span tree appears within a few seconds. The service summary fills in after a few minutes of traffic.
Logs
This guide does not use the Node.js OpenTelemetry logs SDK yet. Send logs with your existing logger to the OTLP collector. See OpenTelemetry Collector.
Troubleshooting
- No spans arrive. A gRPC exporter cannot use the HTTP endpoint. Set
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobufand confirm the register hook loads before your app code. - Spans show as
unknown_service:node.OTEL_SERVICE_NAMEdid not reach the process. Set it in the same environment that starts Node. - 401 or 403. 401 means no key was found; check the header is exactly
x-api-keyinOTEL_EXPORTER_OTLP_HEADERS. 403 means the key was read and rejected; check its scope and whether it was rotated.
Next
- Go traces: the SDK setup in main, with otelhttp for handlers.
- Java traces: one JVM flag for the official agent.
- .NET traces: auto-instrumentation and the logging bridge.
- Authentication: every accepted credential header.