Skip to main content

Distributed Tracing

Distributed tracing provides end-to-end visibility into request flows across your infrastructure. Traefik uses OpenTelemetry, an open standard for distributed tracing compatible with Jaeger, Zipkin, and other tracing backends.

Overview

Tracing allows you to:
  • Visualize request propagation across services
  • Identify performance bottlenecks
  • Analyze latency distribution
  • Track errors through the request lifecycle
  • Understand service dependencies
Traefik follows OpenTelemetry semantic conventions v1.37.0.

Quick Start

Enable basic tracing:
By default, traces are sent via HTTPS to https://localhost:4318/v1/traces.

Common Configuration

Service Name

string
default:"traefik"
Service name identifier in the tracing backend.

Sample Rate

float
default:"1.0"
Proportion of requests to trace (0.0 to 1.0).
Set to 0.1 to trace 10% of requests:
The OpenTelemetry SDK also supports the OTEL_TRACES_SAMPLER environment variable for custom sampling strategies.

Add Internals

boolean
default:"false"
Enable tracing for internal resources like ping@internal.

Resource Attributes

object
default:"{}"
Additional resource attributes sent to the collector.

Captured Headers

Capture request and response headers as span attributes:
array
default:"[]"
List of request headers to add as span attributes.
array
default:"[]"
List of response headers to add as span attributes.

Safe Query Parameters

array
default:"[]"
Query parameters to NOT redact (all others are redacted by default).
By default, all query parameters are redacted for security. Specify safe parameters:

OpenTelemetry Configuration

HTTP Protocol

Send traces via HTTP to an OpenTelemetry Collector:

HTTP Configuration Options

string
default:"https://localhost:4318/v1/traces"
URL of the OpenTelemetry Collector.
To disable TLS, use http:// instead of https:// in the endpoint URL.
object
default:"{}"
Additional headers sent with traces.
string
Path to certificate authority file.
string
Path to client certificate file.
string
Path to client private key file.
boolean
default:"false"
Skip TLS certificate verification.

gRPC Protocol

Send traces via gRPC to an OpenTelemetry Collector:

gRPC Configuration Options

string
default:"localhost:4317"
Address of the OpenTelemetry Collector (format: host:port).
boolean
default:"false"
Send traces without using a secured protocol.
object
default:"{}"
Additional headers sent with traces.

Trace Propagation

Traefik supports multiple trace context propagation formats via the OTEL_PROPAGATORS environment variable:
  • tracecontext (default) - W3C Trace Context
  • baggage (default) - W3C Baggage
  • b3 - B3 single header
  • b3multi - B3 multi header
  • jaeger - Jaeger propagation
  • xray - AWS X-Ray
  • ottrace - OT Trace

Configure Propagators

Set multiple propagators:
In Docker Compose:

Backend Integration Examples

Jaeger

Connect to Jaeger via OpenTelemetry Collector:
Or use the Jaeger agent directly with the OpenTelemetry Collector as a sidecar.

Zipkin

Connect to Zipkin via OpenTelemetry Collector:
Configure the OpenTelemetry Collector to export to Zipkin:

AWS X-Ray

Configure for AWS X-Ray:
Set the X-Ray propagator:

Complete Examples

Production Tracing Setup

Development Setup

Docker Compose with Jaeger

Access Jaeger UI at http://localhost:16686.

Span Attributes

Traefik creates spans with OpenTelemetry semantic conventions:

HTTP Span Attributes

  • http.request.method - HTTP method (GET, POST, etc.)
  • http.response.status_code - HTTP status code
  • network.protocol.name - Protocol name (http/1.1, h2, etc.)
  • server.address - Server hostname
  • server.port - Server port
  • url.scheme - URL scheme (http, https)
  • url.path - Request path
  • user_agent.original - User-Agent header

Traefik-Specific Attributes

  • traefik.router.name - Router that handled the request
  • traefik.service.name - Service that handled the request
  • traefik.entrypoint.name - EntryPoint that received the request

Best Practices

Performance Optimization
  • Use sampling (e.g., sampleRate: 0.1) in high-traffic environments
  • Avoid capturing large headers or sensitive data
  • Monitor collector resource usage
Security
  • Redact sensitive query parameters (default behavior)
  • Use TLS for collector connections in production
  • Avoid capturing Authorization headers unless necessary
  • Secure the collector endpoint with authentication
Troubleshooting
  • Verify collector connectivity with --log.level=DEBUG
  • Check trace sampling configuration
  • Validate propagation headers in requests
  • Monitor collector for errors