Hello there! You've found one of my OpenTelemetry playgrounds. This example contains everything you need to know to use the OpenTelemetry Javascript Tracing API when running in Node:
- Initialization: How to start and shutdown cleanly.
- Tracer methods: getTracer, getCurrentSpan, startSpan, and withSpan.
- Span methods: setAttribute, addEvent, recordException, setStatus, and end.
This example uses OpenTelemetry JS v0.12 and Lightstep as the backend. It contains heavily commented examples of every pattern needed to trace your code with OpenTelemetry.
Relevant handy links:
- Free Lightstep Community Account: make a free account if you don't already have one, or modify the setup instructions to match your analysis tool of choice.
- OTel Node Launcher: https://github.com/lightstep/otel-launcher-node/
- Quickstart Guide: https://opentelemetry.lightstep.com/js
npm i express
npm i lightstep-opentelemetry-launcher-node
Since we’re connecting to Lightstep, we’re using the Lightstep Distro of OpenTelemetry, the OpenTelemetry Launchers. If you're interested in details about Distros, you can read about their origins here.
I also recommend turning on the debug logs, to get a sense of what OpenTelemetry is doing.
export OTEL_LOG_LEVEL=debug
The only required configuration to set your access token. You can find it under "settings" in your lightstep account. Hit the copy button, then open server_init.js and client_init.js and paste that giant thing where it says
Run the traced entry points in two terminals:
node server_init.js
node client_init.js