← Lessons

quiz vs the machine

Silver1100

System Design

Context Propagation Deep Dive

How trace identity rides along with a request so spans in different services join the same tree.

4 min read · intro · beat Silver to climb

The Problem

Services do not share memory. When service A calls service B, B has no idea which trace it belongs to unless A tells it. Context propagation is the mechanism that carries trace identity across that boundary.

What Travels

The minimum payload is the trace context:

  • The trace id, shared by every span in the request.
  • The current span id, which becomes the parent for spans B creates.
  • Sampling flags telling B whether this trace is being recorded.

Two Halves

Propagation has two sides. The caller injects context into the outgoing carrier, usually HTTP headers or message metadata. The callee extracts it on the way in and starts its spans as children.

If any hop drops the context, the trace breaks into disconnected pieces and you lose end to end visibility. This is why propagation must be wired into every client and server, not just the entry point.

Key idea

Context propagation injects trace id and span id into a request at the caller and extracts them at the callee so spans across services join one tree.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the role of context propagation?

2. What happens if one hop drops the trace context?