How do you trace a request that goes through Kafka from a producer to three consumers?
IntermediateScenarioTracing and OpenTelemetry
Answer
Situation read → Async messaging breaks the simple parent/child chain.
What I'd do →
- Use instrumented Kafka clients (OTel Java agent,
opentelemetry-instrumentation-kafka-python, confluent-kafka instrumentations) so the producer injectstraceparentinto message headers. - Consumers extract context and create a span with a link to the producer span (or a child, depending on semantics).
- Use messaging semantic conventions (
messaging.system,messaging.destination.name). - Track consumer lag as a metric alongside traces.
Why → Links represent fan-out and batch processing better than strict parent/child.
Interview tip → Mention span links for batch consumers that process messages from many traces at once.
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