Span

Struct Span 

Source
pub struct Span<T>(/* private fields */);
Expand description

Span.

When this span is dropped, it will be converted to FinishedSpan and it will be sent to the associated SpanReceiver.

Implementations§

Source§

impl<T> Span<T>

Source

pub fn inactive() -> Self

Makes an inactive span.

This span is never traced.

§Examples
use cf_rustracing::span::Span;

let span = Span::<()>::inactive();
assert!(! span.is_sampled());
Source

pub fn handle(&self) -> SpanHandle<T>
where T: Clone,

Returns a handle of this span.

Source

pub fn is_sampled(&self) -> bool

Returns true if this span is sampled (i.e., being traced).

Source

pub fn context(&self) -> Option<&SpanContext<T>>

Returns the context of this span.

Source

pub fn set_operation_name<F, N>(&mut self, f: F)
where F: FnOnce() -> N, N: Into<Cow<'static, str>>,

Sets the operation name of this span.

Source

pub fn set_start_time<F>(&mut self, f: F)
where F: FnOnce() -> SystemTime,

Sets the start time of this span.

Source

pub fn set_finish_time<F>(&mut self, f: F)
where F: FnOnce() -> SystemTime,

Sets the finish time of this span.

Source

pub fn set_tag<F>(&mut self, f: F)
where F: FnOnce() -> Tag,

Sets the tag to this span.

Source

pub fn set_tags<F, I>(&mut self, f: F)
where F: FnOnce() -> I, I: IntoIterator<Item = Tag>,

Sets the tags to this span.

Source

pub fn set_baggage_item<F>(&mut self, f: F)
where F: FnOnce() -> BaggageItem,

Sets the baggage item to this span.

Source

pub fn get_baggage_item(&self, name: &str) -> Option<&BaggageItem>

Gets the baggage item that has the name name.

Source

pub fn log<F>(&mut self, f: F)
where F: FnOnce(&mut LogBuilder),

Logs structured data.

Source

pub fn error_log<F>(&mut self, f: F)
where F: FnOnce(&mut StdErrorLogFieldsBuilder<'_>),

Logs an error.

This is a simple wrapper of log method except that the StdTag::error() tag will be set in this method.

Source

pub fn child<N, F>(&self, operation_name: N, f: F) -> Span<T>
where N: Into<Cow<'static, str>>, T: Clone, F: FnOnce(StartSpanOptions<'_, AllSampler, T>) -> Span<T>,

Starts a ChildOf span if this span is sampled.

Source

pub fn follower<N, F>(&self, operation_name: N, f: F) -> Span<T>
where N: Into<Cow<'static, str>>, T: Clone, F: FnOnce(StartSpanOptions<'_, AllSampler, T>) -> Span<T>,

Starts a FollowsFrom span if this span is sampled.

Trait Implementations§

Source§

impl<T: Debug> Debug for Span<T>

Source§

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

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

impl<T> Drop for Span<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> InspectableSpan<T> for Span<T>

Source§

fn operation_name(&self) -> &str

Returns the operation name of this span.

Source§

fn start_time(&self) -> SystemTime

Returns the start time of this span.

Source§

fn finish_time(&self) -> Option<SystemTime>

Returns the finish time of this span.

Source§

fn logs(&self) -> &[Log]

Returns the logs recorded during this span.

Source§

fn tags(&self) -> &[Tag]

Returns the tags of this span.

Source§

fn references(&self) -> &[SpanReference<T>]

Returns the references of this span.

Source§

impl<T> MaybeAsRef<SpanContext<T>> for Span<T>

Source§

fn maybe_as_ref(&self) -> Option<&SpanContext<T>>

Performs the conversion.

Auto Trait Implementations§

§

impl<T> Freeze for Span<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Span<T>
where T: RefUnwindSafe,

§

impl<T> Send for Span<T>
where T: Send,

§

impl<T> Sync for Span<T>
where T: Sync + Send,

§

impl<T> Unpin for Span<T>
where T: Unpin,

§

impl<T> UnwindSafe for Span<T>
where T: UnwindSafe,

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> 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, 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