Struct Span

Source
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

Source

pub fn builder() -> Builder

Returns a builder used to construct a Span.

Source

pub fn trace_id(&self) -> TraceId

The randomly generated, unique identifier for a trace, set on all spans within it.

Source

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.

Source

pub fn parent_id(&self) -> Option<SpanId>

The parent span ID, or None if this is the root span in a trace.

Source

pub fn id(&self) -> SpanId

The unique 64 bit identifier for this operation within the trace.

Source

pub fn kind(&self) -> Option<Kind>

The “kind” of operation this span represents.

When absent, the span is local or incomplete.

Source

pub fn timestamp(&self) -> Option<SystemTime>

The start of the span.

Source

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.

Source

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.

Source

pub fn shared(&self) -> bool

Determines if this span was started by another tracer (e.g. on a different host).

Source

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.

Source

pub fn remote_endpoint(&self) -> Option<&Endpoint>

Returns the other side of the connection for RPC or messaging spans.

Source

pub fn annotations(&self) -> &[Annotation]

Returns the annotations associated with this span.

Source

pub fn tags(&self) -> &HashMap<String, String>

Returns tags used to give spans context for search, viewing, and analysis.

Trait Implementations§

Source§

impl Clone for Span

Source§

fn clone(&self) -> Span

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Span

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Span

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Span, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Span> for Builder

Source§

fn from(s: Span) -> Builder

Converts to this type from the input type.
Source§

impl Serialize for Span

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Span

§

impl RefUnwindSafe for Span

§

impl Send for Span

§

impl Sync for Span

§

impl Unpin for Span

§

impl UnwindSafe for Span

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,