A developer asks: "Should I add a span for every function?" What do you tell them?
BeginnerScenarioTracing and OpenTelemetry
Answer
Situation read → Over-instrumentation adds overhead and noise; under-instrumentation leaves gaps.
What I'd do →
- Let auto-instrumentation cover network boundaries (HTTP, gRPC, DB, cache, queue).
- Add manual spans for meaningful units of work: "calculate price", "reserve inventory", external calls without instrumentation.
- Add attributes (
order.id,customer.tier) rather than more spans. - Use span events for notable moments (retry, cache miss).
Why → Each span costs CPU and storage; aim for the spans that explain latency.
Interview tip → "Span boundaries at I/O and business steps, attributes for context."
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