Struct Span

Source
pub struct Span {
Show 16 fields pub trace_id: Vec<u8>, pub span_id: Vec<u8>, pub tracestate: Option<Tracestate>, pub parent_span_id: Vec<u8>, pub name: Option<TruncatableString>, pub kind: i32, pub start_time: Option<Timestamp>, pub end_time: Option<Timestamp>, pub attributes: Option<Attributes>, pub stack_trace: Option<StackTrace>, pub time_events: Option<TimeEvents>, pub links: Option<Links>, pub status: Option<Status>, pub resource: Option<Resource>, pub same_process_as_parent_span: Option<BoolValue>, pub child_span_count: Option<UInt32Value>,
}
Expand description

A span represents a single operation within a trace. Spans can be nested to form a trace tree. Spans may also be linked to other spans from the same or different trace. And form graphs. Often, a trace contains a root span that describes the end-to-end latency, and one or more subspans for its sub-operations. A trace can also contain multiple root spans, or none at all. Spans do not need to be contiguous - there may be gaps or overlaps between spans in a trace.

The next id is 17. TODO(bdrutu): Add an example.

Fields§

§trace_id: Vec<u8>

A unique identifier for a trace. All spans from the same trace share the same trace_id. The ID is a 16-byte array. An ID with all zeroes is considered invalid.

This field is semantically required. Receiver should generate new random trace_id if empty or invalid trace_id was received.

This field is required.

§span_id: Vec<u8>

A unique identifier for a span within a trace, assigned when the span is created. The ID is an 8-byte array. An ID with all zeroes is considered invalid.

This field is semantically required. Receiver should generate new random span_id if empty or invalid span_id was received.

This field is required.

§tracestate: Option<Tracestate>

The Tracestate on the span.

§parent_span_id: Vec<u8>

The span_id of this span’s parent span. If this is a root span, then this field must be empty. The ID is an 8-byte array.

§name: Option<TruncatableString>

A description of the span’s operation.

For example, the name can be a qualified method name or a file name and a line number where the operation is called. A best practice is to use the same display name at the same call point in an application. This makes it easier to correlate spans in different traces.

This field is semantically required to be set to non-empty string. When null or empty string received - receiver may use string “name” as a replacement. There might be smarted algorithms implemented by receiver to fix the empty span name.

This field is required.

§kind: i32

Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using CLIENT (caller) and SERVER (callee) to identify queueing latency associated with the span.

§start_time: Option<Timestamp>

The start time of the span. On the client side, this is the time kept by the local machine where the span execution starts. On the server side, this is the time when the server’s application handler starts running.

This field is semantically required. When not set on receive - receiver should set it to the value of end_time field if it was set. Or to the current time if neither was set. It is important to keep end_time > start_time for consistency.

This field is required.

§end_time: Option<Timestamp>

The end time of the span. On the client side, this is the time kept by the local machine where the span execution ends. On the server side, this is the time when the server application handler stops running.

This field is semantically required. When not set on receive - receiver should set it to start_time value. It is important to keep end_time > start_time for consistency.

This field is required.

§attributes: Option<Attributes>

A set of attributes on the span.

§stack_trace: Option<StackTrace>

A stack trace captured at the start of the span.

§time_events: Option<TimeEvents>

The included time events.

§links: Option<Links>

The included links.

§status: Option<Status>

An optional final status for this span. Semantically when Status wasn’t set it is means span ended without errors and assume Status.Ok (code = 0).

§resource: Option<Resource>

An optional resource that is associated with this span. If not set, this span should be part of a batch that does include the resource information, unless resource information is unknown.

§same_process_as_parent_span: Option<BoolValue>

A highly recommended but not required flag that identifies when a trace crosses a process boundary. True when the parent_span belongs to the same process as the current span. This flag is most commonly used to indicate the need to adjust time as clocks in different processes may not be synchronized.

§child_span_count: Option<UInt32Value>

An optional number of child spans that were generated while this span was active. If set, allows an implementation to detect missing child spans.

Implementations§

Source§

impl Span

Source

pub fn kind(&self) -> SpanKind

Returns the enum value of kind, or the default if the field is set to an invalid enum value.

Source

pub fn set_kind(&mut self, value: SpanKind)

Sets kind to the provided enum value.

Trait Implementations§

Source§

impl Clone for Span

Source§

fn clone(&self) -> Span

Returns a duplicate 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

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

impl Default for Span

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for Span

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl Name for Span

Source§

const NAME: &'static str = "Span"

Simple name for this Message. This name is the same as it appears in the source .proto file, e.g. FooBar.
Source§

const PACKAGE: &'static str = "opencensus.proto.trace.v1"

Package name this message type is contained in. They are domain-like and delimited by ., e.g. google.protobuf.
Source§

fn full_name() -> String

Fully-qualified unique name for this Message. It’s prefixed with the package name and names of any parent messages, e.g. google.rpc.BadRequest.FieldViolation. By default, this is the package name followed by the message name. Fully-qualified names must be unique within a domain of Type URLs.
Source§

fn type_url() -> String

Type URL for this Message, which by default is the full name with a leading slash, but may also include a leading domain name, e.g. type.googleapis.com/google.profile.Person. This can be used when serializing into the google.protobuf.Any type.
Source§

impl PartialEq for Span

Source§

fn eq(&self, other: &Span) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Span

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more