How do you pass a tenant ID from the gateway to every downstream span without changing every service?
IntermediateScenarioTracing and OpenTelemetry
Answer
Situation read → You want a business attribute on all spans for filtering by customer.
What I'd do →
- At the gateway, set W3C baggage (
baggage: tenant.id=acme). - Instrumented services propagate baggage automatically.
- Add a span processor (e.g. baggage span processor in the SDK contrib packages) to copy baggage entries to span attributes.
- Never put secrets or PII in baggage; it travels in headers, including to third parties if not stripped.
Why → Baggage propagates with the trace context, so one change at the edge reaches all services.
Interview tip → Strip baggage at egress to external APIs.
More on Tracing and OpenTelemetry
Your company has 30 microservices and no tracing. How do you roll out distributed tracing?IntermediateTraces stop at service B: you see spans from A, but B's spans start new traces. What is wrong?BeginnerTracing every request costs too much. How do you design sampling?IntermediateYou set up tail sampling with 4 Collector replicas, but traces are fragmented and error traces are missing. Why?AdvancedA checkout request takes 4 seconds. Walk through how you use a trace to find the cause.BeginnerYour OpenTelemetry Collector is getting OOMKilled under load. How do you stabilise it?Intermediate