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

Span Relationships and Hierarchy

Understanding parent-child and follows-from span relationships that represent causal dependencies in distributed calls.

Span Relationships and Hierarchy

What you'll learn: How parent-child and follows-from relationships between spans represent the causal flow of work in distributed systems.

The Core Idea

In distributed tracing, spans don't exist in isolation—they're connected through relationships that capture how operations depend on each other. The two primary relationship types are:

Parent-Child (ChildOf): The most common relationship. A parent span initiates and waits for a child span to complete. The child represents work directly caused by the parent. For example, when your API handler calls a database query, the query span is a child of the handler span.

Follows-From: A looser relationship indicating that one operation was triggered by another, but the parent doesn't wait for completion. This is typical in async workflows—like when a web request triggers a background job. The background job span "follows from" the request span, but they execute independently.

Why This Matters

These relationships create a hierarchy that maps exactly to your system's call graph. When you visualize a trace:

  • Parent-child links show synchronous dependencies (blocking calls)
  • Follows-from links show asynchronous fire-and-forget patterns
  • The root span (no parent) represents the entry point of your request

The hierarchy enables critical path analysis: by following parent-child relationships, you can identify which operations actually blocked the request and contributed to total latency. A span that "follows from" another won't appear on the critical path because it doesn't block the response.

Think of it like a family tree: parent-child means direct lineage and dependency, while follows-from is like a distant cousin—related, but not in your direct line.

Key Takeaway: Span relationships encode the causal structure of distributed work, with parent-child representing blocking dependencies and follows-from representing asynchronous triggers, forming a hierarchy that reveals your system's actual execution flow.