Testing purpose application on how to instrumentate NodeJS services for Observability using OpenTelemetry SDK
Disclaimer: Docker, NodeJS and TypeScript must be installed!
- Set up the environmental variables
export OTEL_SERVICE_NAME="observe-nodejs"
export OTEL_TRACES_EXPORTER="jaeger"
export OTEL_METRICS_EXPORTER="prometheus"
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="http://localhost:9090/"
- Install the project dependencies
npm i
- Set up the Jaeger service
docker run --rm \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 9411:9411 \
jaegertracing/all-in-one:latest
- Set up the Prometheus service
docker run --rm -v ${PWD}/prometheus.yml:/prometheus/prometheus.yml -p 9090:9090 prom/prometheus --enable-feature=otlp-write-receive
- Run the application
npx ts-node --require ./instrumentation.ts app.ts
After that, the app will be exposed on http://localhost:8080, traces will be available at http://localhost:16686 through Jaeger, and metrics can be found at http://localhost:9090 through Prometheus.