Pcornel
Observability · Distributed Tracing

Spans and Trace Context

Cheat sheet · https://pcornel.dk/topic.php?topic=6210

Back to the Topic

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.

Remember

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.

First 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

Verify in this order

incoming traceparent → server span → client span → outgoing traceparent

Where it usually breaks

Missing propagation splits one request into several traces.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6210

Confirmation

Confirm action

Continue?