Practice this topic in a realistic system design interview
Suppose a user clicks the checkout button in an e-commerce application. That single click might pass through an API gateway, an order service, an inventory service, a payment service, a fraud check service, a database, and a message queue.
Now suppose checkout starts taking 6 seconds.
You check the metrics for each service. Several show slightly higher latency, but none clearly stands out. You check the logs. Each service has its own logs, on its own machines, and nothing obviously links the entries from one service to the entries from another.
What you really want to know is simple: for this one slow request, where did the 6 seconds go?
Metrics summarize many requests. Logs describe individual events inside one service. Neither shows the full path of a single request across the system.
That is the problem distributed tracing solves.
In this chapter, we will learn what distributed tracing is, how traces and spans are structured, how trace context moves between services, and how sampling keeps tracing affordable in large systems.