Skip to main content
PreparationZone Logo
PrepZone

Distributed Tracing — Context Propagation

Trace IDs across ShardPay services — follow one transfer through gateway, ledger, and fraud.

Pass checkpoint below

Why this matters

  • Logs alone cannot reconstruct cross-service latency or determine which hop added 150ms to a transfer.
  • OpenTelemetry (OTel) is the industry standard; ShardPay exports traces to Jaeger with 7-day retention.
  • Every on-call incident at ShardPay starts with "find the trace" — not grep across 40 microservice log streams.
  • Interviewers expect you to explain context propagation, sampling trade-offs, and how tracing complements metrics and logs.
Gateway spantrace-id: abc
Ledger spanparent: gateway
Fraud spanparent: ledger
traceparent header links spans across service boundaries.

Context propagation

When a merchant hits POST /transfers, the API gateway creates a root span and injects W3C traceparent into outbound headers. Every downstream service — fraud, ledger shards, notification — extracts the context, creates a child span, and passes context to its own outbound calls.

ShardPay's transfer TXN-a4f2 shows this chain: gateway (12ms) → fraud scoring (94ms) → orchestrator (8ms) → shard-3 debit (41ms) → shard-9 credit (38ms) → outbox publish (6ms). Total 199ms — fraud is the bottleneck, visible immediately in Jaeger.

Key points

  • Trace — the end-to-end journey of one request, identified by a 128-bit trace ID. ShardPay support looks up traces by transferId via a baggage field set at the gateway.
  • Span — one unit of work in one service: name, start/end timestamps, status, attributes. The fraud span includes attributes merchantId, riskScore, and modelVersion.
  • traceparent — W3C header (00-{trace-id}-{span-id}-{flags}) propagated on HTTP and gRPC. ShardPay's gRPC interceptors auto-inject; missing propagation breaks the trace chain.
  • Baggage — optional key-value pairs propagated alongside trace context. ShardPay sets baggage: transferId=TXN-a4f2 at the gateway so every span is searchable by business ID.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • Instrumentation in ShardPay
  • Sampling and storage

Test yourself

Answer these before moving on — recall is what makes it stick.