Try
↑ ↓ move↵ openesc close

Interview prep / Distributed tracing

Junior · Distributed tracing · System design interview question

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.

Learn it by running it

The distributed tracing lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms