How does the trace identifier get from one service to the next?
Sketch your own answer first, then compare it with the one below.
A strong answer
Through context propagation. When a service receives a request, it reads the trace context from the incoming message, usually a header. It makes itself a child span of the caller. When it calls another service, it writes the trace identifier and its own span identifier onto the outgoing message.
The W3C Trace Context standard defines a common header format so services built with different tools can still join one trace.
Instrumentation usually lives in shared libraries, such as the web framework and the client, so application code does not do it by hand. The usual failure is a hop that does not forward the header, such as a queue or a third-party service. The trace then splits in two at that point.
Sources
- Sergey Kanzhelev, Morgan McLean, Alois Reitbauer, Bogdan Drutu, Nik Molnar, Yuri Shkuro (2021). Trace Context.