Pcornel
Browse topics
Options
Recent
Favorites
Observability · Technical reference

Spans and Trace Context

Direct answer

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.

When to use this

Use it when instrumenting code or fixing broken traces.

First 30 seconds

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.

Operational verification

incoming traceparent → server span → client span → outgoing traceparent

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
OpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformOpenTelemetry / Prometheus / Grafana / common metrics-log-trace pipelines
Scope / prerequisiteUse it when instrumenting code or fixing broken traces.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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.

Key points

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.

Key checks
  • curl -v -H 'traceparent: 00-<32hex>-<16hex>-01' http://svc/ — first check for this topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool 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

FieldExample
Name (low cardinality)GET /orders/{id}, SELECT orders
KindSERVER, CLIENT, PRODUCER, CONSUMER, INTERNAL
Start / end timeDuration
Attributeshttp.request.method, http.response.status_code, db.system
EventsTimestamped points inside the span (exception, retry)
StatusUnset, Ok, Error with description
LinksRelations to other traces (batch jobs consuming many messages)

Where propagation breaks

BoundaryFix
Message queues (Kafka, RabbitMQ, SQS)Inject/extract context in message headers; producer and consumer spans
Thread pools and async callbacksCarry the context into the task (most SDK instrumentations do this)
Proxies and gateways that rebuild requestsForward 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Terminology layer

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.

Aliases that resolve here
spans and trace contextdistributed tracing spansw3c traceparent
Confirmation

Confirm action

Continue?