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
Quick Start
Enable basic tracing: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).
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).
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 theOTEL_PROPAGATORS environment variable:
tracecontext(default) - W3C Trace Contextbaggage(default) - W3C Baggageb3- B3 single headerb3multi- B3 multi headerjaeger- Jaeger propagationxray- AWS X-Rayottrace- OT Trace
Configure Propagators
Set multiple propagators:Backend Integration Examples
Jaeger
Connect to Jaeger via OpenTelemetry Collector:Zipkin
Connect to Zipkin via OpenTelemetry Collector:AWS X-Ray
Configure for AWS X-Ray:Complete Examples
Production Tracing Setup
Development Setup
Docker Compose with Jaeger
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 codenetwork.protocol.name- Protocol name (http/1.1, h2, etc.)server.address- Server hostnameserver.port- Server porturl.scheme- URL scheme (http, https)url.path- Request pathuser_agent.original- User-Agent header
Traefik-Specific Attributes
traefik.router.name- Router that handled the requesttraefik.service.name- Service that handled the requesttraefik.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