What is the critical path of a trace, and why is the slowest span not always the one to optimise?
Sketch your own answer first, then compare it with the one below.
A strong answer
The critical path is the chain of spans that determines the end-to-end latency. Follow the trace from the end. When a service calls others in parallel, the path goes through the child that finished last. When it calls them in sequence, the path goes through all of them. The time the path spends in each span's own work adds up to the request latency.
A span off the path can be as slow as you like without affecting the total, because something else is still running when it finishes. A call with the longest own time may be one of several parallel branches, with another branch still going. Making it faster changes nothing.
So rank work by time on the critical path, not by duration or self time alone. Expect the path to move after a fix, because the next-slowest branch becomes the critical one.
Sources
- Michael Chow, David Meisner, Jason Flinn, Daniel Peek, Thomas F. Wenisch (2014). The Mystery Machine: End-to-end Performance Analysis of Large-Scale Internet Services.