TraceContext class final

The identifiers that tie one request's spans to the work it caused.

The wire format is W3C Trace Context, which is what makes a trace survive a hop into a service written in something else: traceparent is 00-<32 hex trace id>-<16 hex span id>-<2 hex flags>. Inventing a format here would mean a trace that stops at the first boundary.

Constructors

TraceContext({required String traceId, required String spanId, required bool sampled})
Creates a context from its parts.
const
TraceContext.start({Random? random, bool sampled = true})
Starts a new trace.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sampled → bool
Whether the trace was sampled, which downstream services honour.
final
spanId → String
This span, 16 hex characters.
final
traceId → String
The trace this belongs to, 32 hex characters.
final
traceparent → String
The traceparent header value for this context.
no setter

Methods

child({Random? random}) → TraceContext
A child of this context: same trace, a new span.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

parse(String? traceparent) → TraceContext?
Reads a traceparent header, or null when it is absent or malformed.