Overview
Distributed tracing enables users to track a request through mesh that is distributed across multiple services. This allows a deeper understanding about request latency, serialization and parallelism via visualization.
Istio leverages Envoy’s distributed tracing5 feature to provide tracing integration out of the box.
Most tracing backends now accept OpenTelemetry6 protocol to receive traces, though Istio also supports legacy protocols for projects like Zipkin7 and Apache SkyWalking8.
Configuring tracing
Istio provides a Telemetry API9 which can be used to configure distributed tracing, including selecting a provider, setting sampling rate10 and header modification.
Extension providers
Extension providers are defined in MeshConfig
, and allow defining the configuration for a trace backend. Supported providers are OpenTelemetry, Zipkin, SkyWalking, Datadog and Stackdriver.
Building applications to support trace context propagation
Although Istio proxies can automatically send spans, extra information is needed to join those spans into a single trace. Applications must propagate this information in HTTP headers, so that when proxies send spans, the backend can join them together into a single trace.
To do this, each application must collect headers from each incoming request and forward the headers to all outgoing requests triggered by that incoming request. The choice of headers to forward depends on the configured trace backend. The set of headers to forward are described in each trace backend-specific task page. The following is a summary:
All applications should forward the following headers:
x-request-id
: an Envoy-specific header that is used to consistently sample logs and traces.traceparent
andtracestate
: W3C standard headers11
For Zipkin, the B3 multi-header format12 should be forwarded:
x-b3-traceid
x-b3-spanid
x-b3-parentspanid
x-b3-sampled
x-b3-flags
For commercial observability tools, refer to their documentation.
If you look at the sample Python productpage
service13, for example, you see that the application extracts the required headers for all tracers from an HTTP request using OpenTelemetry libraries:
The reviews application14 (Java) does something similar using requestHeaders
:
When you make downstream calls in your applications, make sure to include these headers.