What is a Span in Distributed Tracing?
A span is the basic unit of a distributed trace — one named, timed operation with attributes, events, and a parent — and a trace is the tree of spans a single request produces.
A span is the fundamental building block of distributed tracing: a single named, timed operation within a request — an HTTP handler executing, a SQL query running, a message being published. Every span belongs to a trace, and the spans of a trace form a parent-child tree that mirrors the request’s actual call structure.
Anatomy of a span
Each span (as defined by OpenTelemetry) carries:
- Name — the operation, e.g.
GET /api/ordersorSELECT orders - Trace ID — shared by every span in the same request
- Span ID and parent span ID — position in the tree
- Start time and duration — precise timing
- Attributes — key-value context:
http.status_code,db.system,net.peer.name - Events — timestamped moments within the span, such as an exception with its stack trace
- Status — OK or error
- Kind — server, client, producer, consumer, or internal
Spans vs traces
Think of the trace as the story and spans as its sentences. The root span covers the entire request; each downstream call adds a child. Gaps between a parent’s duration and its children’s durations reveal time spent in the service’s own code — often the surprise culprit in latency investigations.
Working with spans effectively
- Name spans by operation pattern (
GET /users/:id), never by unique values, or you’ll create unbounded name cardinality - Follow OpenTelemetry semantic conventions for attribute names so backends can compute service maps and RED metrics automatically
- Record exceptions as span events — it ties stack traces to the exact operation that failed
- At high volume, choose a sampling strategy that always keeps error and slow-path spans
Spans in OpenObserve
OpenObserve ingests OpenTelemetry spans over OTLP, renders them as waterfall trace views in Traces, and lets you query span attributes with SQL — so “all spans where db.statement took >500ms for tenant X” is one query, not an archaeology project.
Frequently asked questions
What is the difference between a span and a trace?
A span is a single timed operation. A trace is the full tree of spans created by one request, linked by a shared trace ID. Every trace has exactly one root span and any number of child spans.
What are span attributes?
Attributes are key-value pairs attached to a span that describe the operation — http.method, db.statement, user tier, region. OpenTelemetry's semantic conventions standardize attribute names so tools can interpret them consistently.
What is a root span?
The root span is the first span of a trace — the one with no parent, usually representing the entry point such as the inbound HTTP request at your edge service. Its duration is the end-to-end latency of the whole request.
Related terms
Keep reading
See these concepts in action
OpenObserve unifies logs, metrics, traces, and frontend monitoring in one open-source platform — at a fraction of the cost of legacy tools.