Distributed Tracing with Jaeger and Grafana Tempo: Setup and Best Practices

When your production incident involves seven microservices, three message queues, and a latency spike that only affects 2% of requests, grep'ing logs and staring at CPU graphs will not save you. I've spent too many nights trying to reconstruct a request's path from disconnected log lines with mismatched timestamps, only to realize the root cause was a downstream dependency that timed out and retried silently. Distributed tracing solves that specific pain by stitching together the entire lifecycle of a request as it hops across service boundaries, giving you a causal timeline rather than a pile of hints. In this article, I’ll walk through how I deploy and operate both Jaeger and Grafana Tempo in Kubernetes environments, when to choose one over the other, and the configuration patterns that keep tracing useful, performant, and affordable at scale.

Why Logs and Metrics Alone Fail to Explain Cross-Service Latency

In my experience, most teams start with two pillars: logs for context and metrics for trends. Both are essential, but neither answers the question "why did this specific user's checkout take 4.2 seconds?" Metrics will show you that p95 latency on payment-service increased, and logs might show a timeout, but you still lack the connection between the frontend request, the auth check, the inventory reservation, and the payment authorization that together made up that 4.2 seconds.

Tracing introduces a third signal that is request-scoped. Each inbound request gets a trace ID, propagated via headers like traceparent (W3C Trace Context), and each unit of work within the request creates a span with a start time, duration, and parent reference. The complete trace becomes a directed acyclic graph of spans. This is not just pretty waterfall diagrams; it gives you the ability to pinpoint the exact span where time was lost, to see parallel vs. sequential execution, and to correlate errors that propagate across services.

I’ve found that teams who adopt tracing without fixing their logging strategy still struggle. If your logs don't contain the trace ID, you can't jump from a slow trace to the relevant application logs. That correlation is where the real value lies. Before adding tracing, instrument your logging library to inject trace_id and span_id into every structured log line. If you are standardizing on JSON logs, the approach I outlined in Structured Logging: JSON Format, Context Fields and Log Aggregation pairs directly with tracing — add those two fields to your standard context map and your ELK or Loki queries become drastically more precise.

From Isolated Diagnostics to End-to-End Visibility

Consider an asynchronous workflow: API gateway -> order-service (sync) -> publishes to Kafka -> inventory-service -> payment-service. Without tracing, you have three disconnected visibility silos: the synchronous HTTP part, the queue lag, and the consumer processing. With proper propagation through Kafka headers (using OpenTelemetry's Kafka instrumentation), a single trace covers the entire flow. I’ve debugged race conditions in exactly this pattern where the producer correctly recorded a span, but the consumer never extracted the context because the header was stripped by a custom serializer. The fix was a two-line change in the interceptor, but without end-to-end tracing you would never know the link was broken.

Architectural Trade-offs: Jaeger's Monolithic Heritage vs Tempo's Object Storage Core

Jaeger and Tempo solve the same problem but from opposite architectural philosophies. Jaeger, originally built at Uber, expects you to query traces by trace ID or service name relatively quickly after ingestion. Its storage backends are Elasticsearch, Cassandra, or Badger for all-in-one. Tempo, built by Grafana Labs, makes a deliberate trade: it minimizes indexing and relies on object storage (S3, GCS, Azure Blob) as the primary store, optimizing for low cost and long retention over fast, arbitrary search.

In practical terms, this changes your operational model. With Jaeger over Elasticsearch, you pay for indexed storage and need to manage index lifecycle, shard sizing, and mapping explosions. Queries like "find all traces where http.status_code=500 and region=us-west" are fast because fields are indexed. With Tempo, that same query requires TraceQL and a scan over Parquet blocks in object storage. It will work, but it is slower and more compute-intensive at query time. Tempo compensates with far lower storage costs — I've seen a 6x reduction in storage spend when moving from a 7-day Jaeger + Elasticsearch cluster to Tempo with 30-day retention on S3 with ZSTD compression.

There is no universal winner. I run Jaeger for short-term, high-fidelity debugging in pre-production and for services that need immediate trace lookup by ID, and Tempo for long-term, high-volume production retention where cost matters more than sub-second tag search. The key is that you don’t have to pick one exclusively if you put an OpenTelemetry Collector in front.

Capability Jaeger Grafana Tempo
Storage Backend Elasticsearch, Cassandra, Badger (in-memory) Object Storage (S3/GCS/Azure) + local WAL
Indexing Model Full indexing of tags and process metadata Minimal indexing (trace ID only); TraceQL scans Parquet blocks
Retention Cost at Scale High — indexes grow linearly with tag cardinality Low — Parquet + compression on cheap object storage
Query Pattern Fast lookup by trace ID, service, operation, tags Fast by trace ID, slower for ad-hoc tag search (requires TraceQL)
Best Fit Dev/staging, immediate debugging, existing ELK investment Production high-volume, long retention, Grafana-native workflows
Integration Surface Jaeger UI, native Grafana data source Grafana Tempo data source, exemplary trace-to-logs correlation

If you already run the ELK Stack Architecture: Elasticsearch, Logstash and Kibana at Scale, Jaeger on Elasticsearch feels familiar operationally — you already know how to scale, snapshot, and monitor Elasticsearch. If you are standardizing on Grafana and want to consolidate traces alongside Prometheus metrics and Loki logs, Tempo’s integration is hard to beat, especially with Grafana’s trace-to-logs and exemplars features.

Deploying Jaeger and Tempo Together on Kubernetes via OpenTelemetry Collector

My preferred production pattern is to never have applications send directly to Jaeger or Tempo. Instead, every service sends OTLP to a local OpenTelemetry Collector sidecar or DaemonSet, and the collector fans out to both backends with different sampling and routing rules. This decouples instrumentation from storage decisions and lets me change retention or add a backend without redeploying services. The Kubernetes Documentation patterns for DaemonSets and sidecars apply directly here, and the Collector itself is stateless enough to run as a Deployment with autoscaling.

Centralizing Ingestion with a Scalable Collector Pipeline

The Collector configuration below is a simplified version of what I run in production. It receives OTLP over gRPC/HTTP, batches aggressively, and exports to both Jaeger (via OTLP) and Tempo. Note the use of memory_limiter and batch processors — without them, a traffic burst will OOM your collectors or create millions of tiny objects in S3.

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  memory_limiter:
    check_interval: 1s
    limit_mib: 1024
    spike_limit_mib: 256
  batch:
    timeout: 2s
    send_batch_size: 8192
  attributes:
    actions:
      - key: environment
        value: production
        action: upsert
      - key: k8s.cluster.name
        value: prod-eu-west-1
        action: upsert

exporters:
  otlp/jaeger:
    endpoint: jaeger-collector.tracing.svc.cluster.local:4317
    tls:
      insecure: true
  otlp/tempo:
    endpoint: tempo-distributor.tracing.svc.cluster.local:4317
    tls:
      insecure: true
    sending_queue:
      num_consumers: 32
      queue_size: 10000

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, attributes, batch]
      exporters: [otlp/jaeger, otlp/tempo]

For high-throughput clusters, I split the Collector into two tiers: a stateless agent DaemonSet that handles batching and attributes, and a stateful gateway Deployment that handles tail sampling decisions (covered next). The gateway tier needs persistent queueing and horizontal scaling based on span rate — I autoscale it on otelcol_exporter_sent_spans and CPU.

Kubernetes Manifests for Tempo with S3 Backend and Jaeger Query

Tempo’s microservices mode is the right choice beyond a few thousand spans per second. The monolithic single binary is excellent for evaluation, but for production I deploy distributor, ingester, querier, compactor, and query-frontend separately. Jaeger can be much simpler: I often run Jaeger’s collector and query components with Elasticsearch as storage for short-term lookup, while Tempo handles the durable copy.

# tempo-config.yaml - excerpt for object storage
storage:
  trace:
    backend: s3
    s3:
      bucket: prod-tempo-traces-eu-west-1
      endpoint: s3.eu-west-1.amazonaws.com
      region: eu-west-1
    wal:
      path: /var/tempo/wal
      encoding: zstd
    block:
      bloom_filter_false_positive: 0.05
      v2_index_downsample_bytes: 1000
      encoding: zstd
    pool:
      max_workers: 100
      queue_depth: 10000

compactor:
  compaction:
    block_retention: 720h  # 30 days
    compacted_block_retention: 1h
    compaction_window: 1h

distributor:
  receivers:
    otlp:
      protocols:
        http:
        grpc:

ingester:
  max_block_duration: 5m
  max_block_bytes: 1073741824 # 1GB

# When using Terraform to provision the S3 bucket and IAM roles,
# follow the provider patterns in the Terraform Documentation
# https://developer.hashicorp.com/terraform/docs

I provision the S3 bucket with versioning disabled, lifecycle rules to transition to Intelligent-Tiering after 7 days, and SSE-S3 encryption. The ingesters need fast local disks for WAL — I use gp3 with 3000 IOPS on EKS, sized at 50GB per ingester pod. Tempo’s compactor is the most sensitive component: if it falls behind, query latency degrades and S3 PUT costs spike. Monitor tempodb_compaction_duration and scale compactor replicas before block retention starts to fail.

Sampling Strategies That Preserve Errors Without Inflating Storage

Collecting 100% of traces at high throughput is technically possible with Tempo’s cheap storage, but it still creates query noise and network overhead. Sampling is where most teams make expensive mistakes — either sampling too aggressively at the head and losing error traces, or sampling everything and drowning in data.

Head sampling decides at trace creation whether to keep it, typically 1-10%. It is cheap and simple, but it is blind to the outcome — it will drop a trace that later results in a 500 error with equal probability. Tail sampling decides after the trace is complete, allowing you to keep 100% of traces with errors, high latency, or specific status codes, and only a fraction of healthy traces. The trade-off is that tail sampling requires buffering spans for the sampling window, which means more memory and a centralized gateway.

My rule of thumb: use probabilistic head sampling at the SDK for edge services (sample 10%), then apply tail sampling at the Collector gateway for the final decision. This two-layer approach balances client overhead with intelligence.

Implementing Tail Sampling for Error and Latency Capture

This is the tail sampling processor configuration I deploy in the gateway tier. It keeps all traces with errors, all traces over 1.5 seconds, and only 5% of healthy traces. The composite policy is critical — the order matters, and you want error policies first.

processors:
  tail_sampling:
    decision_wait: 10s
    num_traces: 100000
    expected_new_traces_per_sec: 8000
    policies:
      - name: errors-policy
        type: status_code
        status_code: {status_codes: [ERROR]}
      - name: slow-traces-policy
        type: latency
        latency: {threshold_ms: 1500}
      - name: key-service-policy
        type: string_attribute
        string_attribute: {key: http.route, values: ["/api/checkout", "/api/payment"]}
      - name: probabilistic-policy
        type: probabilistic
        probabilistic: {sampling_percentage: 5}
  # Ensure you export with probabilistic sampling disabled at exporters
  # when tail sampling is enabled to avoid double sampling

connectors:
  spanmetrics:
    namespace: traces.spanmetrics
    histogram:
      explicit:
        buckets: [100ms, 250ms, 500ms, 1s, 2s, 5s]

service:
  pipelines:
    traces/gateway:
      receivers: [otlp]
      processors: [tail_sampling]
      exporters: [spanmetrics, otlp/jaeger, otlp/tempo]

Two practical lessons here. First, decision_wait must be longer than your longest expected trace duration. If you have async jobs that span 30 seconds, set it to 35-40s or you’ll make decisions on incomplete traces. Second, the spanmetrics connector is invaluable — it derives RED metrics (rate, errors, duration) from traces directly, giving you service-level SLIs without additional instrumentation. I scrape those metrics into Prometheus and alert on them via the setup described in Prometheus and Alertmanager: Complete Setup for Production Monitoring.

Correlating Traces with Logs and Metrics Through Exemplars and Trace IDs

A trace becomes far more powerful when you can pivot from it to the exact logs that occurred during that trace, and when you can jump from a Prometheus spike to representative traces. Grafana’s correlation features handle this if you provide the glue: consistent trace IDs and exemplars.

For logs, configure your application logger to extract the current span context and inject it. In Go with slog and OpenTelemetry:

// Pseudocode: ensure every log line carries trace context
logger = slog.With(
  "trace_id", span.SpanContext().TraceID().String(),
  "span_id", span.SpanContext().SpanID().String(),
)

// Loki/Grafana can then link via derived fields:
// In Grafana data source config, add:
// Derived field: trace_id -> internal link to Tempo data source

In Grafana, configure the Loki data source with a derived field that detects trace_id and links to Tempo, and configure Tempo to link back to logs using the logs section in the data source. Now a trace view shows a “Logs for this span” button that runs a Loki query like {app="payment-service"} |= "trace_id=4bf92f3577b34da6a3ce929d0e0e4736" scoped to the span’s time window. This pattern has reduced my mean time to root cause by at least half for data-related issues where the error message is only in logs.

For metrics, enable exemplars in Prometheus. Exemplars attach a trace ID to histogram buckets. When you see a latency spike in a Grafana heatmap, you can click the exemplar dot and jump straight to the trace that contributed to that bucket. Enable it in Prometheus with --enable-feature=exemplar-storage and in the OpenTelemetry Collector with prometheusremotewrite or by exposing metrics from the spanmetrics connector. The Docker Documentation is surprisingly useful when testing exemplar flows locally with Docker Compose before rolling to Kubernetes — it clarifies host networking and volume mounts for Prometheus config.

Finally, enforce context propagation at every hop: HTTP clients, gRPC interceptors, message queue producers/consumers, and background jobs. I audit this quarterly by running a synthetic trace generator that sends a request with a known trace ID and verifies that every downstream service emitted a span with the same ID. Missing propagation is silent and pervasive.

Tuning Retention, Compaction and Query Performance for Production Scale

Retention is not a single number. I define three tiers: real-time (last 2 hours, fully in ingesters, instant query), recent (2 hours to 72 hours, in S3 compacted blocks, fast query), and historical (3 days to 30 days, in S3 with larger blocks, slower TraceQL). Tempo’s ingester max_block_duration and compactor settings control this transition. Smaller blocks mean faster recent queries but more S3 LIST operations and cost.

For Jaeger with Elasticsearch, retention is governed by index lifecycle management. I use weekly indices with a 7-day retention and force-merge to one segment before snapshot. Field cardinality is the killer — avoid indexing high-cardinality attributes like user_id or request_body as indexed tags. Keep them as log fields or non-indexed span attributes. I’ve seen a single deployment emit http.url with query strings and blow Elasticsearch mapping limits within hours.

Query performance tuning: In Tempo, set query_frontend with caching (Redis or Memcached) for repeated TraceQL queries. Increase querier.query_timeout to 2 minutes for TraceQL scans over 30 days — the default 30 seconds will time out on broad searches. In Jaeger, protect Elasticsearch by putting a query rate limiter in front and setting QUERY_MAX_CLOCK_SKEW_ADJUSTMENT to avoid overly broad time ranges.

Operational Guardrails and Cost Control

Set spans-per-second limits on the Collector gateway and drop traces gracefully with the filter processor when limits are exceeded, rather than letting ingesters backpressure. Monitor cardinality of service.name and span.name — I alert if either exceeds 100 distinct values per hour, which usually indicates a dynamic URL or customer ID leaking into span names. And tag every trace with deployment.environment, k8s.pod.ip, and service.version; when a canary deployment causes latency regression, that attribute lets you filter traces to just the canary pods without extra tooling.

Storage cost control in Tempo: enable ZSTD compression, set block_retention deliberately, and use S3 lifecycle to abort incomplete multipart uploads after 3 days. One team I worked with saved $3,800/month just by aborting failed compactor uploads that lingered as invisible S3 parts. For deeper cost and compliance retention planning, see Log Rotation and Retention: Storage Optimization and Compliance Requirements — the same principles around retention tiers and legal hold apply to traces, especially if you store PII in span attributes.

Frequently Asked Questions

Should I replace Jaeger entirely with Tempo if I'm already on Grafana?

Not necessarily. In my setups, Jaeger remains useful for short-term, indexed tag search and for teams already invested in Elasticsearch operational knowledge. Tempo excels at long-term, low-cost retention and deep Grafana integration. Running both behind an OpenTelemetry Collector lets you gradually shift retention to Tempo while keeping Jaeger for fast lookups during the migration. Evaluate query patterns first: if you rely heavily on ad-hoc search across custom tags, Jaeger will feel faster initially.

How do I trace asynchronous jobs and message queues without creating orphaned traces?

Propagation is the key. Instrument your producer to inject the current trace context into message headers (Kafka, RabbitMQ, SQS) and your consumer to extract it before creating a child span. With OpenTelemetry, use the appropriate instrumentation library for your client and ensure your serializer preserves headers. Test with a synthetic trace and verify in the UI that consumer spans appear as children of the producer span, not as separate root traces. If headers are stripped, you will see two disconnected traces with different trace IDs.

What sampling rate should I start with in production?

Start with 5-10% head sampling at the SDK plus tail sampling at the Collector gateway that keeps 100% of errors, traces over your SLO threshold (e.g., 1s), and 5% of healthy traffic. This typically results in 8-15% effective storage while preserving every actionable trace. Measure span ingestion rate and storage growth for a week before tuning. If you store traces in Tempo on S3, storage cost is low enough that you can be more generous initially and tighten later.

Why do my traces appear broken or missing spans in the UI?

Common causes are clock skew between hosts, incomplete context propagation, and sampler misconfiguration. Ensure NTP is synchronized across nodes, verify that every HTTP/gRPC client and message queue propagates W3C Trace Context, and check that head and tail samplers are not conflicting. Also confirm that the Collector's batch timeout is not too long and that tail_sampling.decision_wait exceeds your longest trace duration; otherwise the sampler decides before all spans arrive.

Related Articles

References & Standards: Kubernetes Documentation · Docker Documentation · Terraform Documentation