Skip to main content
Sampling in a distributed OpenTelemetry system requires coordination between services to ensure consistent sampling decisions across your entire application. In a microservice architecture, every service needs to use the same sampling method to maintain trace consistency. Without this coordination, you might end up with incomplete traces where some spans are sampled while others are not.

Main Orchestrating Application

Set the sampling method in your primary service that initiates requests:
from atla_insights import configure
from atla_insights.sampling import TraceRatioSamplingOptions

configure(
    token=os.environ["ATLA_INSIGHTS_TOKEN"],
    sampling=TraceRatioSamplingOptions(rate=0.10)  # 10% sampling rate
)

All Other Microservices

Configure downstream services to inherit the sampling decision from the main application:
from atla_insights import configure
from opentelemetry.sdk.trace.sampling import ParentBased, ALWAYS_ON

configure(
    token=os.environ["ATLA_INSIGHTS_TOKEN"],
    sampling=ParentBased(ALWAYS_ON)  # Inherits decision from parent trace
)

How This Works

  1. Parent-based sampling: The ParentBased(ALWAYS_ON) sampler checks if there’s a parent span from another service
  2. Inheritance: If a parent span exists and was sampled, the child service will also sample
  3. Consistency: This ensures that either the entire distributed trace is sampled or none of it is
I