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>
impl<T> Span<T>
Sourcepub fn inactive() -> Self
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());Sourcepub fn handle(&self) -> SpanHandle<T>where
T: Clone,
pub fn handle(&self) -> SpanHandle<T>where
T: Clone,
Returns a handle of this span.
Sourcepub fn is_sampled(&self) -> bool
pub fn is_sampled(&self) -> bool
Returns true if this span is sampled (i.e., being traced).
Sourcepub fn context(&self) -> Option<&SpanContext<T>>
pub fn context(&self) -> Option<&SpanContext<T>>
Returns the context of this span.
Sourcepub fn set_operation_name<F, N>(&mut self, f: F)
pub fn set_operation_name<F, N>(&mut self, f: F)
Sets the operation name of this span.
Sourcepub fn set_start_time<F>(&mut self, f: F)where
F: FnOnce() -> SystemTime,
pub fn set_start_time<F>(&mut self, f: F)where
F: FnOnce() -> SystemTime,
Sets the start time of this span.
Sourcepub fn set_finish_time<F>(&mut self, f: F)where
F: FnOnce() -> SystemTime,
pub fn set_finish_time<F>(&mut self, f: F)where
F: FnOnce() -> SystemTime,
Sets the finish time of this span.
Sets the tags to this span.
Sourcepub fn set_baggage_item<F>(&mut self, f: F)where
F: FnOnce() -> BaggageItem,
pub fn set_baggage_item<F>(&mut self, f: F)where
F: FnOnce() -> BaggageItem,
Sets the baggage item to this span.
Sourcepub fn get_baggage_item(&self, name: &str) -> Option<&BaggageItem>
pub fn get_baggage_item(&self, name: &str) -> Option<&BaggageItem>
Gets the baggage item that has the name name.
Sourcepub fn log<F>(&mut self, f: F)where
F: FnOnce(&mut LogBuilder),
pub fn log<F>(&mut self, f: F)where
F: FnOnce(&mut LogBuilder),
Logs structured data.
Sourcepub fn error_log<F>(&mut self, f: F)where
F: FnOnce(&mut StdErrorLogFieldsBuilder<'_>),
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.
Trait Implementations§
Source§impl<T> InspectableSpan<T> for Span<T>
impl<T> InspectableSpan<T> for Span<T>
Source§fn operation_name(&self) -> &str
fn operation_name(&self) -> &str
Returns the operation name of this span.
Source§fn start_time(&self) -> SystemTime
fn start_time(&self) -> SystemTime
Returns the start time of this span.
Source§fn finish_time(&self) -> Option<SystemTime>
fn finish_time(&self) -> Option<SystemTime>
Returns the finish time of this span.
Returns the tags of this span.
Source§fn references(&self) -> &[SpanReference<T>]
fn references(&self) -> &[SpanReference<T>]
Returns the references of this span.