Use it when instrumenting code or fixing broken traces.
Spans and Trace Context
A span is one timed operation in a trace with name, start/end, status, attributes and parent; trace context (W3C traceparent: version-traceid-spanid-flags) propagates IDs between services.
1. Inspect header: curl -v -H 'traceparent: 00-<32hex>-<16hex>-01' http://svc/.
2. Child spans have the right parent.
3. Propagators configured (tracecontext, baggage).
4. Queue messages carry context.
5. Error status set.
incoming traceparent → server span → client span → outgoing traceparent
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Compare trace duration with measured request latency. Confirm error spans carry status and exception details.
Step 2 Common failures Narrow the fault
Missing propagation splits one request into several traces. Span names with IDs explode cardinality. Clock skew between hosts makes child spans appear before parents.
Every outbound call must inject context and every inbound handler extract it. Proxies and message queues must pass headers. Mark error status on failed spans.
curl -v -H 'traceparent: 00-<32hex>-<16hex>-01' http://svc/— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
ReferenceWhat it is1 section · depth on demand
How it works
SDKs create spans automatically for frameworks and clients, and code adds manual spans for important steps. The span tree shows where time is spent and which call failed.
ReferenceImportant terms & boundaries3 sections · depth on demand
Trace context
W3C Trace Context passes IDs between services in HTTP headers:
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
version-trace-id-parent-span-id-flags(sampled)
Illustrative output, not captured Evidence. Every service must propagate the header (auto-instrumentation does this for common libraries); a missing hop breaks the trace into pieces. Spans carry attributes (http.route, db.system), events and status.
In depth
The traceparent header field by field
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
│ │ │ └ flags: 01 = sampled
│ │ └ parent-id: 16 hex — the caller's span
│ └ trace-id: 32 hex — same for the whole request
└ version
Each service keeps the trace-id, creates its own span with a new span-id, and sends that span-id as the parent-id downstream. tracestate carries vendor-specific data alongside it.
What a span records
| Field | Example |
|---|---|
| Name (low cardinality) | GET /orders/{id}, SELECT orders |
| Kind | SERVER, CLIENT, PRODUCER, CONSUMER, INTERNAL |
| Start / end time | Duration |
| Attributes | http.request.method, http.response.status_code, db.system |
| Events | Timestamped points inside the span (exception, retry) |
| Status | Unset, Ok, Error with description |
| Links | Relations to other traces (batch jobs consuming many messages) |
Where propagation breaks
| Boundary | Fix |
|---|---|
| Message queues (Kafka, RabbitMQ, SQS) | Inject/extract context in message headers; producer and consumer spans |
| Thread pools and async callbacks | Carry the context into the task (most SDK instrumentations do this) |
| Proxies and gateways that rebuild requests | Forward traceparent and tracestate |
| Legacy formats (B3, Jaeger) | Configure the propagator list, for example OTEL_PROPAGATORS=tracecontext,baggage,b3multi |
Reading a waterfall
Look for: the longest span on the critical path; gaps between child spans (time spent in the parent's own code or waiting for a thread); many sequential identical child spans (N+1 queries); and client spans much longer than the matching server span (network, connection pool or queueing in between).
The W3C spec forbids putting personal data in tracestate; the same caution applies to span attributes.
Common mistakes
- Not propagating trace context across services.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.