📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Microservices Distributed Tracing

Distributed Tracing

5 min read Quiz at the end
Distributed tracing tracks requests across services with spans — Jaeger and OpenTelemetry are the standard.

Distributed Tracing

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider

tracer = trace.get_tracer(__name__)

@app.post("/orders")
def create_order(order: OrderCreate):
    with tracer.start_as_current_span("create-order") as span:
        span.set_attribute("user.id", order.user_id)
        span.set_attribute("items.count", len(order.items))
        # trace_id propagates via HTTP headers to child services
        result = inventory_client.reserve(order.items)
        span.add_event("inventory-reserved")
        return result

# Tools: Jaeger, Zipkin, Datadog APM, Tempo (Grafana)
# W3C Trace Context header propagation:
# traceparent: 00-{trace_id}-{span_id}-01
Topic Quiz · 1 questions

Test your understanding before moving on

1. What tool is used for distributed tracing to follow a request across multiple services?
💡 Jaeger (with OpenTelemetry instrumentation) visualises trace spans across multiple microservices.