How do the `ParentBased` and `TraceIdRatioBased` samplers work together?

AdvancedConceptTracing & OpenTelemetry
Answer

TraceIdRatioBased(0.1) makes a deterministic decision from the trace ID, so every service using the same ratio agrees on the same trace. ParentBased wraps it: if there is an incoming parent, follow the parent's decision; only root spans use the ratio.

export OTEL_TRACES_SAMPLER=parentbased_traceidratio
export OTEL_TRACES_SAMPLER_ARG=0.1

Without ParentBased, a downstream service with a different ratio would drop spans of traces the upstream kept, producing broken traces. Other options: always_on, always_off, parentbased_always_on (the default). Also note: an unsampled span is still created for context propagation; it is just not recorded or exported.

All Monitoring & Observability questions Roadmap: Logging & tracing

More on Tracing & OpenTelemetry