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 const fn inactive() -> Self
pub const 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.
Sourcepub fn set_finish_callback<C>(&mut self, cb: C)where
C: Into<FinishSpanCallback<T>>,
pub fn set_finish_callback<C>(&mut self, cb: C)where
C: Into<FinishSpanCallback<T>>,
Sets the finish callback for this span.
Sourcepub fn take_finish_callback(&mut self) -> Option<FinishSpanCallback<T>>
pub fn take_finish_callback(&mut self) -> Option<FinishSpanCallback<T>>
Extracts any inherited or explicitly added finish callback from this span.
This can be used either to unset the callback, by discarding the returned value, or to wrap it in a new callback.
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.
Sourcepub 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>,
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.
The child will inherit this span’s finish callback, if it has one. To avoid
this kind of inheritance, you can use span.handle().child(...) instead.
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.