Node.js OpenTelemetry traces with no code changes
Install @opentelemetry/auto-instrumentations-node, start your app with --require @opentelemetry/auto-instrumentations-node/register, and set OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000. Your Node service's traces then show up in Buggregator as a waterfall of spans, with no Jaeger, Grafana or cloud account.
Steps
1. Start Buggregator
OTLP over HTTP uses the main port, 8000. There is no gRPC port.
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Install the auto-instrumentation
npm install --save @opentelemetry/api
npm install --save @opentelemetry/auto-instrumentations-node3. Set the OTel variables
The service name is what the UI shows in the Service column. Set the protocol to http/protobuf or http/json: Buggregator does not accept grpc. In Docker Compose, replace 127.0.0.1 with the Buggregator service name, for example buggregator.
OTEL_SERVICE_NAME=checkout
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf4. Start the app with the register hook
Your code stays as it is.
node --require @opentelemetry/auto-instrumentations-node/register app.js5. Open Sentry, then Traces
Call a few endpoints of your service. Open http://127.0.0.1:8000, the Sentry page, Traces. Each trace has an OTel label and the services it went through. Open one to see its spans as a waterfall with a Service column. A span with status ERROR is marked as an error.
Why it works
The auto-instrumentation package hooks into common Node libraries, such as the HTTP server and clients, and creates spans without code changes. The OTel SDK exports them over OTLP to the endpoint you set, adding /v1/traces. Buggregator accepts OTLP over HTTP on its main port and shows the traces next to your Sentry data. OTel data creates no cards in the main event feed.
Docs: docs.buggregator.dev/config/opentelemetry.html#otel-sdk
Requires Buggregator v2.12.0+
Related tips
- OpenTelemetry
Add Buggregator to your OTel Collector as one more exporter
Add an otlphttp exporter to your Collector config. Traces and logs from every service show up in Buggregator, and the apps stay as they are.
- Sentry
Express errors and traces locally with @sentry/node
Point @sentry/node at Buggregator and load it before Express. Route errors, request traces and logs of your Express app show up on your machine.
- OpenTelemetry
FastAPI traces with OpenTelemetry, shown as a waterfall
Run FastAPI under opentelemetry-instrument and point the standard OTEL_ env vars at Buggregator. Each request's spans show up as a local waterfall.
- OpenTelemetry
Go service traces with OpenTelemetry, no Jaeger to run
Send OTLP/HTTP from your Go service to Buggregator on port 8000. Traces show as a span waterfall and logs link to their trace, on your machine.
Checked on with Buggregator v2.13.0