Interview Prep/Monitoring & Observability/Tracing and OpenTelemetry

Tracing every request costs too much. How do you design sampling?

IntermediateScenarioTracing and OpenTelemetry
Answer

Situation read → 100% tracing at high volume is expensive; random 1% misses the interesting traces.

What I'd do →

  1. Head sampling in SDKs: OTEL_TRACES_SAMPLER=parentbased_traceidratio, OTEL_TRACES_SAMPLER_ARG=0.1 as a base.
  2. Tail sampling in the Collector gateway to keep all errors, slow requests and important routes:
processors:
  tail_sampling:
    decision_wait: 10s
    policies:
      - {name: errors, type: status_code, status_code: {status_codes: [ERROR]}}
      - {name: slow, type: latency, latency: {threshold_ms: 1000}}
      - {name: baseline, type: probabilistic, probabilistic: {sampling_percentage: 5}}
  1. Keep RED metrics from 100% of spans (spanmetrics connector) so rates stay accurate.

Why → You keep the traces worth reading and still get accurate aggregate metrics.

Interview tip → Explain that tail sampling needs all spans of a trace on the same collector (load-balancing exporter by trace ID).

All Monitoring & Observability questions Roadmap: Logging & tracing

More on Tracing and OpenTelemetry