Skip to main content

SpanCombinator

Trait SpanCombinator 

Source
pub trait SpanCombinator {
    // Required methods
    fn record_token_usage<U>(&self, usage: &U)
       where U: GetTokenUsage;
    fn record_response_metadata<R>(&self, response: &R)
       where R: ProviderResponseExt;
    fn record_model_input<T>(&self, messages: &T)
       where T: Serialize;
    fn record_model_output<T>(&self, messages: &T)
       where T: Serialize;
}
Expand description

A trait designed specifically to be used with Spans for the purpose of recording telemetry. Implemented for tracing::Span to record GenAI semantic convention fields.

Required Methods§

Source

fn record_token_usage<U>(&self, usage: &U)
where U: GetTokenUsage,

Record Rig-normalized token usage fields on the span.

Source

fn record_response_metadata<R>(&self, response: &R)

Record provider response metadata such as response ID and model name.

Source

fn record_model_input<T>(&self, messages: &T)
where T: Serialize,

Record serialized model input messages.

Source

fn record_model_output<T>(&self, messages: &T)
where T: Serialize,

Record serialized model output messages.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SpanCombinator for Span

Source§

fn record_token_usage<U>(&self, usage: &U)
where U: GetTokenUsage,

Source§

fn record_response_metadata<R>(&self, response: &R)

Source§

fn record_model_input<T>(&self, input: &T)
where T: Serialize,

Source§

fn record_model_output<T>(&self, output: &T)
where T: Serialize,

Implementors§