span context
also: trace context, distributed context
Span context is metadata that travels with a request or operation through a distributed system, enabling tracing and correlation of related events across different services and processes.
In observability and distributed tracing, span context contains identifiers and metadata that connect related operations together. It typically includes a trace ID (unique identifier for an entire request chain), span ID (identifier for the current operation), and flags indicating sampling decisions or debug mode.
When a service processes a request and makes calls to downstream services, it propagates the span context through HTTP headers, message queues, or other transport mechanisms. This allows tracing systems like Jaeger or Zipkin to reconstruct the full execution path of a request across multiple services.
Example: A user requests a web application, which calls a database service. The initial span context with trace-id=abc123 is created, and when the web app calls the database, it includes that same trace ID in the request headers so the database operation is linked to the parent request in the trace visualization.