Skip to content

Distributed Trace Pipeline: From Tail Sampling to Tempo Service Graphs

Interactive Diagram

새 탭 ↗

The otel-apps Deployment receives all OTLP trace/metric/log data sent by applications, but the three signal pipelines diverge right after the receiver stage. Only the trace pipeline goes through a separate processor chain.

processors:
tail_sampling:
decision_wait: 10s
policies:
- name: latency-policy
type: latency
latency: { threshold_ms: 500 }
- name: error-policy
type: status_code
status_code: { status_codes: [ERROR] }
- name: probabilistic-policy
type: probabilistic
probabilistic: { sampling_percentage: 5 }
memory_limiter:
check_interval: 5s
limit_percentage: 80
resource:
attributes:
- key: service.instance.id
action: insert
from_attribute: k8s.pod.uid
batch:
send_batch_size: 512
timeout: 5s

The order is tail_sampling → memory_limiter → resource/transform → batch. Tail sampling comes first so that every processor after the sampling decision only handles spans that will actually be exported, cutting unnecessary work.

PolicyConditionPurposeRetained
latency-policylatency ≥ 500msPrioritize capturing slow requests100% retained
error-policystatus = ErrorRoot cause analysis100% retained
probabilistic-policyRemaining normal requestsBaseline performance visibility5% sampled

Policies are evaluated with OR logic: if any one of the three conditions is met, that trace is forwarded to Tempo.

The earlier integrated-observability post stated “10% of normal traffic collected.” The actual probabilistic_policy.sampling_percentage value in the deployed otel-apps manifest is 5. From this post forward, 5% is the value used.

PlantUML Diagram
  • Traces are written distributor → ingester → Azure Blob, and the compactor prunes old blocks against a 168h retention window.
  • Query-frontend/querier handles reads; the gateway is enabled but multitenancy is disabled.

From trace to metric: spanmetrics and service graphs

Section titled “From trace to metric: spanmetrics and service graphs”

Only sampled traces are stored in Tempo, but metric derivation happens against every span received, before sampling. otel-apps’s spanmetrics connector extracts request count/latency/error rate from every incoming span and remote-writes it to Mimir, while Tempo’s Metrics Generator separately turns inter-service call relationships into metrics using service_graphs, span_metrics, and the local blocks processor.

# Tempo Metrics Generator configuration (generalized)
metrics_generator:
processors:
- service-graphs
- span-metrics
- local-blocks
registry:
external_labels:
source: tempo
storage:
remote_write:
- url: http://mimir-gateway.mimir.svc.cluster.local/api/v1/push
PlantUML Diagram

Thanks to this structure, even though only the sampled 5% of traces persist, the overall request rate, error rate, and service map stay accurate because they’re derived from 100% of spans.

Grafana’s Tempo datasource has correlation settings that let you jump from a trace ID to logs/metrics/profiles. This is covered in detail alongside the datasource configuration in part 5, the Dashboard post. Here it’s enough to note that traces are the underlying data behind the service map/node graph.

  • Tail sampling is stateful: every span belonging to one trace has to arrive at the same Collector instance for a sampling decision to be made. Simply horizontal-scaling otel-apps without hashing on service.name or traceID could scatter spans of the same trace across different instances and break the sampling decision.
  • A single-replica development environment constraint: this issue hasn’t surfaced yet because otel-apps currently runs at a single replica. Scaling out would first require trace affinity, e.g., a load-balancing exporter that routes the same trace to the same instance.

Dashboards and correlation continue in Operating Grafana Dashboards: Signal Correlation and GitOps Boundaries.