Skip to main content

Span

A span is the basic unit of distributed tracing, a single named, timed operation with attributes and parent-child links that together compose a trace.

A span is the fundamental building block of distributed tracing. It represents a single named operation, such as an HTTP handler, a database query, or a function call, with a defined start time and end time. Many spans linked together form a trace.

How It Works

Each span carries a name, start and end timestamps, a span ID, and the trace ID of the request it belongs to. Spans are arranged in a parent-child hierarchy: a span that triggers further work becomes the parent of the spans created by that work, capturing the causal structure of the request. Spans also hold attributes, which are key-value pairs describing the operation, and events, which mark notable moments. The root span represents the entire request, while nested spans represent the sub-operations beneath it.

Why It Matters

Because each span records its own duration and context, spans reveal exactly how long each step of a request took and how the steps relate. This makes them the unit of analysis for diagnosing latency and errors in distributed systems. Attributes attached to spans, such as a user ID or query text, let engineers filter and group traces to find patterns. The OpenTelemetry standard defines a common span model so spans from different languages and services interoperate.

Related Terms

Spans are the components of distributed tracing and a key form of telemetry within observability. They complement metrics for analyzing performance.