Skip to main content
RunBook Academy

KubernetesXC · Distributed TracingTracing

Trace context propagation — the W3C standard

Advanced⏱ ~13 minkubectlopentelemetry

What you'll learn

  • Explain the W3C Trace Context
  • Use the traceparent and tracestate headers
  • Propagate the context across services
  • Identify the failure modes of the propagation

Prerequisites

Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16

Not yet marked complete on this device.

The W3C Trace Context is the standard for context propagation. The traceparent header is the link; the tracestate header is the vendor-specific extension. This lesson walks the W3C standard, the propagation, the sampling flags, and the failure modes.

The W3C Trace Context

The W3C Trace Context:

traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01

The format:

  • version: 00 (current version)
  • trace-id: 32 hex characters (16 bytes)
  • parent-id: 16 hex characters (8 bytes)
  • trace-flags: 2 hex characters (1 byte)

The traceparent header

The traceparent header:

traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01

The fields:

  • version: 00
  • trace-id: 0af7651916cd43dd8448eb211c80319c
  • parent-id: b7ad6b7169203331
  • trace-flags: 01 (sampled)

The trace-flags

The trace-flags:

01: sampled
00: not sampled

The trace-flags indicate whether the trace is sampled.

The tracestate header

The tracestate header:

tracestate: vendor1=value1,vendor2=value2

The tracestate is the vendor-specific extension. It allows vendors to add their own context.

The propagation across services

The propagation:

sequenceDiagram
    participant C as Client
    participant A as API
    participant B as Backend
    C->>A: GET /api/users with traceparent
    A->>B: forward with traceparent
    B-->>A: response
    A-->>C: 200 OK
    Note over C,B: trace_id is the same. span_id differs

The propagation is the link.

The HTTP propagation

The HTTP propagation:

GET /api/users HTTP/1.1
Host: api.example.com
traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01
tracestate: vendor1=value1

The HTTP headers are the propagation.

The gRPC propagation

The gRPC propagation:

gRPC metadata: "traceparent" = "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01"
gRPC metadata: "tracestate" = "vendor1=value1"

The gRPC metadata is the propagation.

The OpenTelemetry propagation

The OpenTelemetry propagation:

import (
    "go.opentelemetry.io/otel/propagation"
)

otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
    propagation.TraceContext{},
    propagation.Baggage{},
))

The OpenTelemetry provides the propagators.

The auto-instrumentation propagation

The auto-instrumentation:

// The OTel auto-instrumentation hooks the HTTP client
// and adds the traceparent header automatically.
client := http.Client{
    Transport: otelhttp.NewTransport(http.DefaultTransport),
}

The auto-instrumentation automatically propagates the context.

The failure modes

The common failure modes:

Missing header

The traceparent header is missing.
The downstream service creates a new trace.

The mitigation is to ensure all services use the OTel SDK with the auto-instrumentation.

Wrong format

The traceparent header is malformed.
The downstream service rejects the trace.

The mitigation is to validate the header format.

Sampling mismatch

The upstream service samples the trace.
The downstream service does not sample.
The trace is broken.

The mitigation is to use the same sampling strategy.

The correlation with logs

The correlation:

{
  "timestamp": "2026-08-16T10:00:00.000Z",
  "level": "INFO",
  "message": "Request processed",
  "trace_id": "0af7651916cd43dd8448eb211c80319c",
  "span_id": "b7ad6b7169203331"
}

The trace IDs in the logs enable correlation.

The cross-course references

  • The OpenTelemetry course covers the SDK.
  • The Jaeger course covers the trace backend.
  • The Grafana course covers the trace UI.

Quiz

Knowledge check · 4 questions

  1. Q1. What is the format of the traceparent header?

  2. Q2. The tracestate header is the vendor-specific extension.

  3. Q3. Walk the trace context propagation for a workload.

    Workload: HTTP API with 3 services. The team is configuring the trace context propagation.

  4. Q4. What is the sampling flag in the traceparent header?

Passing score: 75%. Answers are checked in this browser.

Production discipline

  • Use the W3C Trace Context. The standard.
  • Propagate the traceparent header. The HTTP / gRPC.
  • Configure the propagators. TraceContext, Baggage.
  • Use the auto-instrumentation. The zero-code integration.
  • Add the trace IDs to the logs. The correlation.
  • Document the propagation. The SDK, the headers.

The trace context propagation is the cluster’s tracing foundation. Operating it well is via the W3C standard, with the propagators, and the auto-instrumentation.