When would you reach for a trace instead of logs or metrics?
Sketch your own answer first, then compare it with the one below.
A strong answer
Use metrics to see that something is wrong and how widely: rates, errors, latency percentiles. They are cheap and aggregate over all requests, but they have forgotten which request was which.
Use logs to see what a service did in detail. They are rich, but a log line in one service does not say which upstream request caused it unless an identifier is attached.
Use a trace when you need to know where one request spent its time across services: which call was slow, whether calls ran in parallel or in sequence, and what the critical path was.
In practice you chain them. An alert fires on a metric, a trace of one slow request finds the slow span, and the logs of that span give the cause.
Sources
- Benjamin H. Sigelman, Luiz André Barroso, Mike Burrows, Pat Stephenson, Manoj Plakal, Donald Beaver, Saul Jaspan, Chandan Shanbhag (2010). Dapper, a Large-Scale Distributed Systems Tracing Infrastructure.