Question #37 of 60•Microservices•Hard• ~3 min read

How does Distributed Tracing (Jaeger / Zipkin) trace requests across microservices?

Executive Takeaway

Explore Trace IDs, Span IDs, OpenTelemetry context propagation headers, and async sampling strategies.

Architectural Breakdown & AnalysisFAANG Aligned

In microservice architectures, a single user click triggers calls across dozens of services. Distributed tracing tracks request execution paths across boundaries.

Context Propagation Headers (W3C Trace Context)

Services inject HTTP headers into downstream RPC requests:

  • traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
  • Trace ID (`4bf9...`): Unique identifier shared across the entire call graph.
  • Span ID (`00f0...`): Unique identifier for an individual operation within a service.

Head-Based vs Tail-Based Sampling

  • Head-Based Sampling: Decides to sample a trace at the initial API Gateway. Efficient, but might miss rare errors.
  • Tail-Based Sampling: Collects all spans first, sampling 100% of traces containing HTTP 5xx errors or latency anomalies.
NOTE — Standard Framework

Standardize telemetry instrumentation across languages using OpenTelemetry (OTel).

Key Architectural Comparison

Tracing PrimitiveScopeInformation ContainedPropagation Header
Trace IDEntire end-to-end request lifecycle across all microservices.Globally unique 64/128-bit identifier.traceparent (W3C standard)
Span IDSingle unit of contiguous work within a specific microservice.Start time, duration, service name, tags, error flags.traceparent
BaggageCross-cutting user/tenant context passed across RPC boundaries.User ID, tenant tier, feature flags.baggage
Previous QuestionWhen should you choose Long Polling vs Server-Sent Events (SSE) vs WebSockets?Next Question How do you design a Multi-Region Active-Active Disaster Recovery Architecture?

Continue Learning on Being SDE

Explore deep-dive system architecture modules, low-level object-oriented designs, and interview cheat sheets.