Tracing
What is it?
Tracing follows a single request as it travels through all the services and steps of a system, showing where time is spent.
Explain like I'm 5
Why was it created?
In distributed systems, a slow request can touch many services. Tracing was adopted to follow it end to end and find the bottleneck.
Where is it used?
- Debugging distributed systems
- Finding latency bottlenecks
- Following requests across services
- Root-cause analysis
Why should developers care?
Tracing is the key tool for debugging performance and failures across microservices, a common need in modern systems.
How does it work?
Each request gets a unique trace ID. As it passes through services, each step records a 'span' (a timed operation) tagged with that ID. Collected together, the spans reconstruct the request's full path and timing.
Real-world example
A slow checkout trace shows the request spent 50ms in the API but 800ms waiting on the inventory service — pinpointing the culprit.
Common use cases
- Pinpointing slow services
- Understanding request flow
- Debugging cross-service errors
- Performance optimization
Advantages
- Shows end-to-end request flow
- Pinpoints bottlenecks
- Invaluable for microservices
- Connects cause across services
Disadvantages
- Requires instrumentation everywhere
- Data volume can be large
- Sampling needed at scale
- More complex to set up
When should you use it?
When requests cross multiple services and you need to see where time or errors occur.
When should you avoid it?
For a simple single-service app, where logs and metrics may be enough.
Alternatives
Related terms
Interview questions
Beginner
- What is tracing?
- What is a trace ID?
Intermediate
- What is a span?
- Why is tracing useful in microservices?
Senior
- Why and how do you sample traces at scale?
- How do traces complement logs and metrics?
Common misconceptions
- "Tracing is just detailed logging" — it specifically follows one request's path across services with timing.
- "You can trace everything at full volume" — at scale you sample to control cost.
Fun facts
- A trace is made of spans, each a timed operation with the shared trace ID.
- Distributed tracing is what makes a slow microservice visible among many.
Timeline
- 2010s — Distributed tracing popularized by large-scale microservice systems
Learning resources
Quick summary
Tracing follows a single request across all services as timed spans, revealing where latency and errors occur in distributed systems.
Cheat sheet
- Follows one request end to end
- Made of timed spans + trace ID
- Pinpoints bottlenecks
- Sample at scale