Course contentsShow
← System Design
Lesson 1221 of 1,91931. Observability: TracingFree lesson

Traces, Spans, and Parent-Child Relationships

Core tracing concepts: a trace represents an end-to-end request, spans represent individual operations within it.

Traces, Spans, and Parent-Child Relationships

You'll learn the core building blocks of distributed tracing and how they represent request journeys.

What Is a Trace?

A trace represents the complete journey of a single end-to-end request through your distributed system. When a user clicks "checkout" on your e-commerce site, that one action might trigger dozens of service calls—payment processing, inventory checks, shipping calculations, notification emails. The trace captures this entire story from start to finish.

What Is a Span?

A span represents a single operation or unit of work within that trace. Each service call, database query, or cache lookup becomes its own span. Think of spans as chapters in the trace's story—each has a start time, end time, operation name, and contextual metadata.

For example, your checkout trace might contain spans like:

  • process_payment (250ms)
  • check_inventory (80ms)
  • calculate_shipping (120ms)
  • send_confirmation_email (45ms)

Parent-Child Relationships

Spans form a tree structure through parent-child relationships. When the payment service calls the fraud detection service, the payment span becomes the parent and fraud detection becomes its child. This hierarchy shows causality—what triggered what.

Think of it like a family tree: the root span (the initial request) is the great-grandparent, and every nested operation becomes a descendant. This structure lets you visualize exactly how the request cascaded through your system and where time was spent.

The parent-child links are what make distributed tracing "distributed"—they connect operations across service boundaries, letting you follow a request's path even as it hops between microservices.

Key Takeaway: A trace is the full request journey, spans are individual operations within it, and parent-child relationships connect spans to show the call hierarchy across services.