Course contentsShow
← Cloud and Infrastructure
Lesson 2063 of 2,98944. Observability - TracingFree lesson

Spans and Span Relationships

Understanding parent-child span relationships and how they form a trace tree structure.

Spans and Span Relationships

What You'll Learn

You'll understand how individual spans connect through parent-child relationships to form a complete trace tree that visualizes a distributed request's journey.

The Building Blocks of a Trace

A span represents a single unit of work in your distributed system—like a function call, database query, or HTTP request. But spans don't exist in isolation; they connect to tell the full story of a request.

Think of a trace like a family tree. Each span is a person, and the relationships between them show how one operation triggered another. The root span (the ancestor) represents the initial request that started everything. Child spans branch off, representing work that happened as a consequence of their parent.

Parent-Child Relationships

When Service A calls Service B, Service A's span becomes the parent, and Service B's span becomes the child. This parent-child relationship is established through the trace context you learned about earlier—the parent passes its span ID to the child.

Example hierarchy:

[Root: Web Request]
  ├─ [Child: Database Query]
  ├─ [Child: Cache Check]
  └─ [Child: External API Call]
      └─ [Grandchild: API's Database Query]

Each span contains its parent's span ID, allowing tracing systems to reconstruct the entire tree. The root span has no parent ID—it's where the request originated.

The Trace Tree Structure

Multiple related spans with the same trace ID form a trace tree. The tree structure reveals:

  • Sequential operations (spans that follow one after another from the same parent)
  • Parallel operations (sibling spans happening concurrently)
  • Nested operations (children within children)
  • Total request path (every service and operation touched)

This tree makes it easy to identify bottlenecks—just look for the longest branches or widest span durations.

Key Takeaway: Spans form parent-child relationships through shared trace context, creating a tree structure that maps exactly how a request flows through your distributed system, revealing both the path taken and the time spent at each step.