pub struct GenAIOperation { /* private fields */ }Expand description
Records a GenAI span plus operation duration and token usage metrics.
Implementations§
Source§impl GenAIOperation
impl GenAIOperation
Sourcepub fn mark_error(
&mut self,
error_type: impl Into<String>,
description: impl Into<String>,
)
pub fn mark_error( &mut self, error_type: impl Into<String>, description: impl Into<String>, )
Marks the operation span and duration metric as failed.
Sourcepub fn record_error<E>(&mut self, err: &E)where
E: Error + 'static,
pub fn record_error<E>(&mut self, err: &E)where
E: Error + 'static,
Records an error object and marks the operation as failed.
Sourcepub fn set_attribute(&mut self, attribute: KeyValue)
pub fn set_attribute(&mut self, attribute: KeyValue)
Sets a span attribute. gen_ai.response.model is also added to metric attributes.
Sourcepub fn set_response_metadata(
&mut self,
response_id: Option<&str>,
response_model: Option<&str>,
finish_reasons: &[&str],
)
pub fn set_response_metadata( &mut self, response_id: Option<&str>, response_model: Option<&str>, finish_reasons: &[&str], )
Attaches common GenAI response metadata to the span.
Sourcepub fn record_usage(&mut self, usage: TokenUsage)
pub fn record_usage(&mut self, usage: TokenUsage)
Records GenAI token usage on the span and token usage metric.
Trait Implementations§
Source§impl Debug for GenAIOperation
impl Debug for GenAIOperation
Auto Trait Implementations§
impl Freeze for GenAIOperation
impl !RefUnwindSafe for GenAIOperation
impl Send for GenAIOperation
impl Sync for GenAIOperation
impl Unpin for GenAIOperation
impl UnsafeUnpin for GenAIOperation
impl !UnwindSafe for GenAIOperation
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> 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>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request