Span represents a single operation within a trace. Spans can be nested to form a trace tree. Often, a trace contains a root span that describes the end-to-end latency and, optionally, one or more sub-spans for its sub-operations.
A span contains a SpanContext and allows users to record tracing events based on the data model defined here.
Represents all the information that MUST be propagated to child Spans and across process boundaries. A span context contains the tracing identifiers and the options that are propagated from parent to child Spans.
Is the identifier for a trace. It is worldwide unique with practically sufficient probability by being made as 16 randomly generated bytes. TraceId is used to group all spans for a specific trace together across all processes.
Is the identifier for a span. It is globally unique with practically sufficient probability by being made as 8 randomly generated bytes. When passed to a child Span this identifier becomes the parent span id for the child Span.
Represents the options for a trace. It is represented as 1 byte (bitmap).
0x1
).Carries tracing-system specific context in a list of key value pairs. Tracestate allows different vendors propagate additional information and inter-operate with their legacy Id formats.
For more details see this.
The implementation MUST allow users to create two types of Spans:
When creating a Span the implementation MUST allow users to create the Span attached or detached from the Context, this allows users to manage the interaction with the Context independently of the Span lifetime:
Context interaction represents the process of attaching/detaching a Span to the Context in order to propagate it in-process (possibly between threads) and between function calls.
There are two supported implementations for the Context based on how the propagation is implemented:
When an implicit propagated Context is used, the implementation MUST use scoped objects to attach/detach a Span (scoped objects represent auto closable objects, e.g. stack allocated objects in C++):
WithSpan
.StartSpan
or StartScopedSpan
.When an explicit propagated Context is used, the implementation MUST create a new Context when a Span is attached (immutable Context):
WithSpan
.StartSpan
or StartScopedSpan
.Span lifetime represents the process of recording the start and the end timestamps to the Span object: