What Is the Difference Between a Trace and a Span?
A trace follows a single request through a distributed system, start to finish. A span is one timed step inside it. A complex request can produce dozens, and each child span keeps a reference to the parent span that called it.
Each service that does part of the work writes its own span. All of them carry the same trace identifier, which the tracing backend later uses to find each span and put the journey back together in order.
Consider a customer who selects "Place order" in an online store. One trace covers the entire order, up to the moment the confirmation page appears. Inside that trace are four spans:
The web front end receiving the request
The call to the inventory service
The database query that checks stock
The call to the payment gateway
Both terms come up wherever one request touches several components. Microservices are the most common case, along with Kubernetes workloads, and serverless functions and AI pipelines follow the same pattern. In distributed tracing (following requests from one service to the next), these two terms are the starting point for everything else.
What Is a Span in a Trace?
A span in a trace is a single named operation, with a start time, an end time and a result, and it's the smallest piece of work tracing captures. Developers decide where one span ends and the next begins. HTTP requests and database queries are typical. A message put on a queue can be one, and so can a call to a language model.
Requests start with a root span, the one span with no parent. Anything created under it becomes a child span. Each span also holds its own timestamps, so its duration shows the latency of that one step alone.
Every span is given a kind label. The label tells the backend which role a span played in the exchange:
Server: Handles an incoming request
Client: Makes an outgoing call to another service
Internal: Does work inside a single service
Producer: Sends a message to a queue or stream
Consumer: Picks up a message from a queue or stream
What Is a Trace in Observability?
A trace in observability is the end-to-end view of a single request, assembled from every span that request produced. Looking at one, you can tell what happened to the request, the order it happened in and where the time was spent. The backend never saves a separate trace record. It keeps spans, and the trace is simply all the spans that share one trace ID.
On screen, tracing tools tend to show it as a waterfall. Spans appear as bars along a timeline (each one indented under its parent), which makes it easy to spot calls that ran back to back, calls that overlapped, and whichever step held up the response. Often that's a slow API call.
How Does a Trace Compare to a Span?
A trace covers an entire request; a span covers one step of it, and most other differences follow from that. The table lays them out by scope, identity and use.
Aspect | Trace | Span |
What it represents | The full path of one request | One operation along that path |
Identifier | Trace ID, shared by all its spans | Span ID, unique to that operation |
How it is stored | Assembled from matching spans | Emitted as its own record by one service |
Parent | None | A parent span, unless it is the root |
Timing | Derived from its spans | Its own start and end timestamps |
Attributes and events | Only through its spans | Carried directly |
Crosses service boundaries | Yes | No, the next service starts a child span |
Main question it answers | What happened to this request? | Where was the time spent or an error raised? |
What Is the Difference Between a Trace ID and a Span ID?
A trace ID is a label for the entire request, and it gets copied onto every span the request produces. A span ID belongs to one operation only. In OpenTelemetry, an open standard for collecting telemetry data, these two work with a third field:
Trace ID: A 16-byte value, shown as 32 hexadecimal (base-16) characters, that stays the same for every span in the request
Span ID: An 8-byte value, shown as 16 hexadecimal characters, that is unique to one span
Parent span ID: The span ID of the caller, which links each child back to its parent; the root span leaves it empty
These IDs move between services through context propagation, which passes them in a standard request header called traceparent. When the next service reads it, its spans join the same trace.
This becomes useful during an incident. Copy the trace ID from an error log entry, paste it into search, and the full request comes up.
What Does a Span Contain?
A span contains a short name, for example "GET /checkout", plus the timestamps, IDs and kind covered earlier. It also carries four fields that explain what happened:
Status: Unset, ok or error
Attributes: Key-value pairs that add context, such as the HTTP method or customer tier
Events: Timestamped notes inside the span, such as an exception or a retry
Links: References to spans in other traces, used for batch jobs and queued messages
Attribute names follow OpenTelemetry's semantic conventions, a shared naming scheme. Because of that, two different tools will read the same database or HTTP attribute in the same way.
How Do Spans Form a Trace in OpenTelemetry?
Spans turn into a trace in OpenTelemetry only once they've left the application. Services emit spans, and the backend assembles the trace from them in four steps:
Create: Instrumentation produces the spans. That can be a software development kit (SDK) added to the code, an agent that instruments common libraries automatically, or eBPF, a Linux kernel technology that captures calls without code changes.
Propagate: Each service passes the trace ID and its own span ID to the next service in request headers.
Export: Services send their spans, usually over OTLP (the OpenTelemetry Protocol), to a collector, a service that receives, processes and forwards telemetry, or straight to the backend.
Assemble: The backend groups spans by trace ID, then connects each span to its parent by matching its parent span ID to that parent’s span ID.
If one service drops the headers, its downstream spans start a new trace, and the request shows up in fragments.
To control storage, sampling keeps only a share of traces. Head-based sampling decides when a request starts, while tail-based sampling waits until it finishes, so slow and failed traces can be kept. This span model came to OpenTelemetry from earlier projects such as OpenTracing.
What Are Common Mistakes with Traces and Spans?
The most common mistakes with traces and spans either break a trace apart or make spans hard to query:
Lost context: A proxy or message queue drops the trace headers, so one request splits into several traces.
Too many spans: Wrapping every function adds storage cost and buries the steps that matter.
Changing span names: User IDs in a span name stop spans from grouping; they belong in attributes.
Unset status on failure: A failed span without an error status drops out of error rate views.
How Do Traces and Spans Help with Troubleshooting?
Traces and spans help with troubleshooting at three levels: a single request, many requests at once, and the logs and business context around them.
One request: An engineer reads the waterfall to find the span that ran longest or failed. Since child spans can run in parallel, total request time is set by the critical path, the longest chain of spans where each waits on the one before.
Many requests: Spans work as a dataset. Grouping them by service or endpoint shows the p99 latency of each operation, and a scatter plot of trace durations exposes outliers that averages hide. Calls between parent and child spans in different services also reveal dependencies, which is how service maps, diagrams of how services call each other, are drawn.
Logs and business context: With the trace ID stamped on every log line, an engineer can move from a slow span straight to that request's logs, which shortens root cause analysis. Tagging spans with business attributes, such as checkout or payment, also lets IT leaders track performance by business transaction.
Explore More IT Terms
Browse our comprehensive IT glossary to learn more about technology terminology.