pub struct SpanGuard { /* private fields */ }Expand description
Stopwatch for one observed span that records on explicit finish or Drop.
Implementations§
Source§impl SpanGuard
impl SpanGuard
Sourcepub fn new(
manager: Arc<ObservabilityManager>,
context: SpanContext,
event_type: EventType,
) -> SpanGuard
pub fn new( manager: Arc<ObservabilityManager>, context: SpanContext, event_type: EventType, ) -> SpanGuard
Creates a span guard with success status and an immediate start time.
Sourcepub fn set_tokens(&mut self, tokens: ObservationTokenUsage)
pub fn set_tokens(&mut self, tokens: ObservationTokenUsage)
Attaches token usage collected from provider output or estimation.
Sourcepub fn set_status(&mut self, status: EventStatus)
pub fn set_status(&mut self, status: EventStatus)
Overrides the final status before recording.
Sourcepub fn set_error(&mut self, error: ObservationError)
pub fn set_error(&mut self, error: ObservationError)
Marks the span as failed and attaches error metadata.
Sourcepub fn set_payload(&mut self, payload: Value)
pub fn set_payload(&mut self, payload: Value)
Attaches optional payload data that will be redacted by the manager.
Sourcepub fn add_tag(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn add_tag(&mut self, key: impl Into<String>, value: impl Into<String>)
Adds a safe tag to the event before recording.
Sourcepub fn record_now(&mut self)
pub fn record_now(&mut self)
Records the span immediately and prevents duplicate Drop recording.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpanGuard
impl !RefUnwindSafe for SpanGuard
impl Send for SpanGuard
impl Sync for SpanGuard
impl Unpin for SpanGuard
impl UnsafeUnpin for SpanGuard
impl !UnwindSafe for SpanGuard
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.