Distributed tracing is the cornerstone of modern observability. It lets us follow requests as they move across microservices, databases, caches, and message queues. At high throughputs (50k+ requests per second), however, the telemetry stream itself becomes a major load.
Here we outline the architecture decisions we made when building a tracing pipeline capable of handling tens of thousands of spans per second without degrading production clusters.
The Architecture
Our tracing pipeline was structured so telemetry collection never interferes with core business traffic:
- Local Instrumentation: Standard OpenTelemetry SDKs embedded in Go and Rust microservices.
- Local Agents (DaemonSets): Lightweight collectors running on each Kubernetes node, batching and forwarding spans off the host so application pods never block on remote network calls.
- Stateful Tail-Sampling Gateway: A scalable tier of telemetry collectors written in Rust (Ingest Engine) behind a trace-ID-aware load balancer. Consistent hashing on
trace_idguarantees every span for a given trace lands on the same collector instance. - Storage & Queue Layer: Fast buffering into Apache Kafka before micro-batching into ClickHouse columnar storage (queried via Jaeger's gRPC storage plugin), replacing our initial Elasticsearch cluster which suffered from high JVM memory overhead and indexing CPU limits.
Challenge 1: The Sampling Strategy
We quickly realized that collecting 100% of traces is both financially prohibitive and technically unnecessary. Most traces represent successful requests with identical execution paths.
We implemented a hybrid sampling strategy:
- Head-based Sampling: High-volume, low-value paths (like health checks) are dropped immediately at the application SDK or local DaemonSet agent before leaving the node.
- Tail-based Sampling: Because a single distributed trace spans multiple services across different Kubernetes nodes, local node agents cannot make trace-wide decisions. Instead, they forward spans to our consistent-hashed gateway tier, which buffers each trace in memory for a short decision window (typically 10–15 seconds). If any span yields an error or the trace exceeds our 200ms latency threshold, the full trace is emitted to Kafka; otherwise, it is discarded.
Holding incomplete traces in memory creates an OOM risk during traffic spikes, which we mitigated with bounded per-collector ring buffers and explicit load-shedding of healthy traces above 85% heap utilization.
Challenge 2: Context Propagation
In heterogeneous environments, traces often break when boundaries are crossed. Passing trace context from our API gateway (Envoy Proxy) to our core services, and then downstream through Kafka, was a frequent point of failure.
In HTTP and gRPC headers, we enforce standard W3C Trace Context:traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
For Kafka topics, producers inject the same traceparent key into Kafka record headers. On the Rust consumer side, we extract the parent context and attach it before starting the consumer span:
use opentelemetry::global;
use opentelemetry::trace::Tracer;
// Extract trace context from Kafka record headers via a custom Extractor
let parent_cx = global::get_text_map_propagator(|propagator| {
propagator.extract(&KafkaHeaderExtractor(&message.headers))
});
let tracer = global::tracer("ingest-consumer");
let _span = tracer.start_with_context("process_kafka_record", &parent_cx);Key Takeaway
Do not treat observability as an afterthought. A tracing pipeline is a distributed system in its own right, requiring consistent-hashed routing, rate-limiting, load-shedding, and strict memory boundaries so it never causes cascading failures in the primary application it monitors.