

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Tracing
incomplete
2: Installing Jaeger
incomplete
3: Request Tracing
incomplete
4: Instrumenting Traces
incomplete
5: Adding Spans
incomplete
6: Reading Traces
incomplete
7: Distributed Tracing
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Tracing records the execution path of a request through a (possibly distributed) system.
You're no doubt familiar with the concept of a "stack trace":
panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
main.(*User).GetName(0x0)
/app/user.go:42 +0x12
main.validateUser(0x0)
/app/validate.go:18 +0x3e
main.main()
/app/main.go:12 +0x2c
In Go, a stack trace is really just a more-or-less human-readable version of a goroutine's stack. And a stack does show some tracing data, because it shows the function at the top of the stack and all of its callers.
But this is more like a "trace snapshot" than a proper trace.
A full request trace ideally shows us all the interesting things that happen throughout the lifecycle of a request – not just a snapshot in time (as a stack trace provides). It can also show us timing information, like this:
Notice that the trace shows the entire path of the request, and it's made up of a series of spans. Each span represents a single unit of work. This lets us break the request down into the parts we care about. For example, if we're talking about a request to a handler that:
We can create one span for each of those steps. When requests are reportedly "slow", we can see which operation is to blame!
We'll focus on two popular open source tools: OpenTelemetry and Jaeger.
Similar to the way that Prometheus and Grafana complement each other to provide a complete metrics ingestion and display package, OpenTelemetry and Jaeger work together to gather and display traces.
OpenTelemetry can do much more than traces, including logging, and metrics. And while there are good reasons to use OpenTelemetry for more than tracing in some cases, we'll be focusing just on tracing for this course.