pub struct Span { /* private fields */ }
Expand description
A Span
represents a single operation over some range of time.
Multiple spans make up a single “trace” of a distributed computation, and spans can be nested. A new trace is created with a “root” span, and subsections of that computation are recorded in individual spans.
For spans tracing a remote service call, two records will typically be generated, one from the client and the other from the server. The client is responsible for recording the timestamp and duration associated with the span, and the server span should omit that information. The client and server may both add their own annotations and binary annotations the span - they will be merged.
Implementations§
Source§impl Span
impl Span
Sourcepub fn trace_id(&self) -> TraceId
pub fn trace_id(&self) -> TraceId
The randomly generated, unique identifier for a trace, set on all spans within it.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
The logical operation this span represents (e.g. an RPC method).
Leave absent if unknown.
These are lookup labels, so take care to ensure names are low cardinality. For example, do not embed variables into the name.
Sourcepub fn parent_id(&self) -> Option<SpanId>
pub fn parent_id(&self) -> Option<SpanId>
The parent span ID, or None
if this is the root span in a trace.
Sourcepub fn kind(&self) -> Option<Kind>
pub fn kind(&self) -> Option<Kind>
The “kind” of operation this span represents.
When absent, the span is local or incomplete.
Sourcepub fn timestamp(&self) -> Option<SystemTime>
pub fn timestamp(&self) -> Option<SystemTime>
The start of the span.
Sourcepub fn duration(&self) -> Option<Duration>
pub fn duration(&self) -> Option<Duration>
The duration of the critical path, if known.
Durations are recorded in microseconds, and rounded up to a minimum of 1. Durations of children can be longer than their parents due to asynchronous operations.
Sourcepub fn debug(&self) -> bool
pub fn debug(&self) -> bool
Determines if this span is part of a normal or forcibly sampled span.
If true, the span should always be sampled regardless of the sampling configuration.
Determines if this span was started by another tracer (e.g. on a different host).
Sourcepub fn local_endpoint(&self) -> Option<&Endpoint>
pub fn local_endpoint(&self) -> Option<&Endpoint>
Returns the host that recorded this span, primarily for query by service name.
Instrumentation should always record this. The IP address is usually the site local or advertised service address. When present, the port indicates the listen port.
Sourcepub fn remote_endpoint(&self) -> Option<&Endpoint>
pub fn remote_endpoint(&self) -> Option<&Endpoint>
Returns the other side of the connection for RPC or messaging spans.
Sourcepub fn annotations(&self) -> &[Annotation]
pub fn annotations(&self) -> &[Annotation]
Returns the annotations associated with this span.
Returns tags used to give spans context for search, viewing, and analysis.