pub struct SpanRef<'a>(/* private fields */);
trace
only.Expand description
A reference to the currently active span in this context.
Implementations§
Source§impl SpanRef<'_>
impl SpanRef<'_>
Sourcepub fn add_event<T>(&self, name: T, attributes: Vec<KeyValue>)
pub fn add_event<T>(&self, name: T, attributes: Vec<KeyValue>)
An API to record events in the context of a given Span
.
Sourcepub fn record_exception(&self, err: &dyn Error)
pub fn record_exception(&self, err: &dyn Error)
Convenience method to record an exception/error as an Event
Sourcepub fn record_exception_with_stacktrace<T>(
&self,
err: &dyn Error,
stacktrace: T,
)
pub fn record_exception_with_stacktrace<T>( &self, err: &dyn Error, stacktrace: T, )
Convenience method to record a exception/error as an Event
with custom stacktrace
Sourcepub fn add_event_with_timestamp<T>(
&self,
name: T,
timestamp: SystemTime,
attributes: Vec<KeyValue>,
)
pub fn add_event_with_timestamp<T>( &self, name: T, timestamp: SystemTime, attributes: Vec<KeyValue>, )
An API to record events at a specific time in the context of a given Span
.
Sourcepub fn span_context(&self) -> &SpanContext
pub fn span_context(&self) -> &SpanContext
Returns the SpanContext
for the given Span
.
Sourcepub fn is_recording(&self) -> bool
pub fn is_recording(&self) -> bool
Returns true if this Span
is recording information like events with the add_event
operation, attributes using set_attributes
, status with set_status
, etc.
Sourcepub fn set_attribute(&self, attribute: KeyValue)
pub fn set_attribute(&self, attribute: KeyValue)
An API to set a single Attribute
where the attribute properties are passed
as arguments. To avoid extra allocations some implementations may offer a separate API for
each of the possible value types.
Sourcepub fn set_status(&self, code: StatusCode, message: String)
pub fn set_status(&self, code: StatusCode, message: String)
Sets the status of the Span
. If used, this will override the default Span
status, which is Unset
. message
MUST be ignored when the status is OK
or Unset
Sourcepub fn update_name<T>(&self, new_name: String)
pub fn update_name<T>(&self, new_name: String)
Updates the Span
’s name. After this update, any sampling behavior based on the
name will depend on the implementation.
Sourcepub fn end_with_timestamp(&self, timestamp: SystemTime)
pub fn end_with_timestamp(&self, timestamp: SystemTime)
Finishes the Span
with given timestamp
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SpanRef<'a>
impl<'a> RefUnwindSafe for SpanRef<'a>
impl<'a> Send for SpanRef<'a>
impl<'a> Sync for SpanRef<'a>
impl<'a> Unpin for SpanRef<'a>
impl<'a> UnwindSafe for SpanRef<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
trace
only.Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
trace
only.