Skip to main content

Span

Struct Span 

Source
pub struct Span {
    pub env: MetaString,
    pub version: MetaString,
    pub component: MetaString,
    pub kind: u32,
    pub attributes: FastHashMap<MetaString, AttributeValue>,
    /* private fields */
}
Expand description

A span event.

Fields§

§env: MetaString

Per-span environment override. Overrides Trace.payload.env when non-empty.

§version: MetaString

Per-span application version.

§component: MetaString

Instrumentation component name.

§kind: u32

Span kind (OTel values): 0=unspecified, 1=internal, 2=server, 3=client, 4=producer, 5=consumer.

§attributes: FastHashMap<MetaString, AttributeValue>

Typed span-level attributes.

Implementations§

Source§

impl Span

Source

pub fn new( service: impl Into<MetaString>, name: impl Into<MetaString>, resource: impl Into<MetaString>, span_type: impl Into<MetaString>, span_id: u64, parent_id: u64, start: u64, duration: u64, error: i32, ) -> Self

Creates a new Span with all required fields.

Source

pub fn with_service(self, service: impl Into<MetaString>) -> Self

Sets the service name.

Source

pub fn with_name(self, name: impl Into<MetaString>) -> Self

Sets the operation name.

Source

pub fn with_resource(self, resource: impl Into<MetaString>) -> Self

Sets the resource name.

Source

pub fn with_span_id(self, span_id: u64) -> Self

Sets the span identifier.

Source

pub fn with_parent_id(self, parent_id: u64) -> Self

Sets the parent span identifier.

Source

pub fn with_start(self, start: u64) -> Self

Sets the start timestamp.

Source

pub fn with_duration(self, duration: u64) -> Self

Sets the span duration.

Source

pub fn with_error(self, error: i32) -> Self

Sets the error flag.

Source

pub fn with_span_type(self, span_type: impl Into<MetaString>) -> Self

Sets the span type (for example, web, db, lambda).

Source

pub fn with_attributes( self, attributes: impl Into<Option<FastHashMap<MetaString, AttributeValue>>>, ) -> Self

Replaces the span attributes map.

Replaces the span links collection.

Source

pub fn with_span_events( self, span_events: impl Into<Option<Vec<SpanEvent>>>, ) -> Self

Replaces the span events collection.

Source

pub fn with_env(self, env: impl Into<MetaString>) -> Self

Sets the per-span environment override.

Source

pub fn with_version(self, version: impl Into<MetaString>) -> Self

Sets the per-span application version.

Source

pub fn with_component(self, component: impl Into<MetaString>) -> Self

Sets the instrumentation component.

Source

pub fn with_kind(self, kind: u32) -> Self

Sets the span kind.

Source

pub fn service(&self) -> &str

Returns the service name.

Source

pub fn name(&self) -> &str

Returns the operation name.

Source

pub fn resource(&self) -> &str

Returns the resource name.

Source

pub fn set_resource(&mut self, resource: impl Into<MetaString>)

Sets the resource name.

Source

pub fn span_id(&self) -> u64

Returns the span identifier.

Source

pub fn parent_id(&self) -> u64

Returns the parent span identifier.

Source

pub fn start(&self) -> u64

Returns the start timestamp.

Source

pub fn duration(&self) -> u64

Returns the span duration.

Source

pub fn error(&self) -> i32

Returns the error flag.

Source

pub fn span_type(&self) -> &str

Returns the span type.

Returns the span links collection.

Returns a mutable reference to the span links collection.

Source

pub fn span_events(&self) -> &[SpanEvent]

Returns the span events collection.

Source

pub fn span_events_mut(&mut self) -> &mut Vec<SpanEvent>

Returns a mutable reference to the span events collection.

Trait Implementations§

Source§

impl Attributes for Span

Source§

type Text = MetaString

Source§

type Bytes = Vec<u8>

Source§

type Values = SalukiValues

Source§

fn attribute_str(&self, key: &str) -> Option<&str>

Get the string value of the attribute for a given key, None if it is missing or not a string.
Source§

fn attribute_f64(&self, key: &str) -> Option<f64>

Get the numeric value of the attribute for a given key, None if it is missing or not a number. Integers are converted to f64.
Source§

fn attribute_i64(&self, key: &str) -> Option<i64>

Get the integer value of the attribute for a given key, None if it is missing, not a number, or a float that isn’t exactly an integer. Read more
Source§

fn has_attribute(&self, key: &str) -> bool

Returns true if an attribute (of any type) exists for key. Read more
Source§

impl AttributesIter for Span

Source§

fn attributes( &self, ) -> impl Iterator<Item = (&str, AttributeRef<'_, SalukiValues>)>

Iterate over all (key, value) attribute pairs, each key at most once
Source§

impl AttributesMut for Span

Source§

fn retain_attributes( &mut self, f: impl FnMut(&str, &mut AttributeValue) -> bool, )

Keep only the attributes for which f returns true; f may mutate the values it keeps. Like [AttributesIter::attributes], f sees each key once.
Source§

fn attribute_mut(&mut self, key: &str) -> Option<&mut AttributeValue>

Get a mutable reference to the value for a given key, None if it is missing
Source§

fn set_attribute(&mut self, key: MetaString, value: AttributeValue)

Set the attribute for key, replacing any existing value for that key
Source§

fn remove_attribute(&mut self, key: &str) -> Option<AttributeValue>

Remove the attribute for key, returning its value if it was present
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() -> Span

Returns the “default value” for a type. Read more
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 Span for Span

Source§

type SpanEvent = SpanEvent

Source§

fn service(&self) -> &str

Source§

fn resource(&self) -> &str

Source§

fn name(&self) -> &str

The operation name
Source§

fn typ(&self) -> &str

The span type (e.g. “web”, “db”)
Source§

fn span_id(&self) -> u64

The id of this span
Source§

fn parent_id(&self) -> u64

The span id of this span’s parent, 0 for a trace root
Source§

fn start(&self) -> i64

The start timestamp, in nanoseconds since the unix epoch
Source§

fn duration(&self) -> i64

The duration, in nanoseconds
Source§

fn is_error(&self) -> bool

Returns true if the span is an error
Source§

fn span_kind(&self) -> Option<&str>

The span kind (e.g. “server”, “client”), None if unset.
Source§

fn env(&self) -> Option<&str>

The env the span was emitted from, None if unset.
Source§

fn version(&self) -> Option<&str>

The application version, None if unset.
Source§

fn component(&self) -> Option<&str>

The instrumentation component, None if unset.
Source§

fn span_events(&self) -> impl Iterator<Item = &SpanEvent>

Iterate over the events attached to this span
Iterate over the links attached to this span
§

fn compat(&self) -> &CompatSpan<Self>
where Self: Sized,

View this span’s attributes the way v0.4 meta/metrics would hold them, promoted tags included. See [CompatSpan].
§

fn is_trace_root(&self) -> bool

Returns true if the span is a trace root
§

fn has_top_level(&self) -> bool

Returns true if the span is marked as top-level, by either the tracer or trace-utils
§

fn is_measured(&self) -> bool

Returns true if the span should be measured (i.e., it should get trace metrics computed)
§

fn is_partial_snapshot(&self) -> bool

Returns true if the span is a partial snapshot of a long-running span
Source§

impl SpanMut for Span

Source§

fn set_service(&mut self, value: MetaString)

Source§

fn set_resource(&mut self, value: MetaString)

Source§

fn set_name(&mut self, value: MetaString)

Set the operation name
Source§

fn set_type(&mut self, value: MetaString)

Set the span type (e.g. “web”, “db”)
Source§

fn set_parent_id(&mut self, value: u64)

Set the span id of this span’s parent, 0 for a trace root
Source§

fn set_start(&mut self, value: i64)

Set the start timestamp, in nanoseconds since the unix epoch
Source§

fn set_duration(&mut self, value: i64)

Set the duration, in nanoseconds
Source§

fn set_error(&mut self, value: bool)

Source§

fn set_span_kind(&mut self, value: &str)

Set the span kind (e.g. “server”, “client”). Implementations storing the kind as an enum map unrecognized values to their default kind.
Source§

fn set_env(&mut self, value: MetaString)

Source§

fn set_version(&mut self, value: MetaString)

Source§

fn set_component(&mut self, value: MetaString)

Source§

fn span_events_mut(&mut self) -> impl Iterator<Item = &mut SpanEvent>

Iterate mutably over the events attached to this span
Iterate mutably over the links attached to this span
§

fn compat_mut(&mut self) -> &mut CompatSpan<Self>
where Self: Sized,

View this span mutably the way v0.4 meta/metrics would hold its attributes, promoted tags included. See [CompatSpan].
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 UnsafeUnpin 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
§

impl<T> Track for T

§

fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>

Instruments this type by attaching the given resource group token, returning a Tracked wrapper. Read more
§

fn in_current_resource_group(self) -> Tracked<Self>

Instruments this type by attaching the current resource group, returning a Tracked wrapper. 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> 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
Source§

impl<T> CloneAny for T
where T: Any + Clone,