pub struct LlmSpan {Show 15 fields
pub span_id: SpanId,
pub trace_id: TraceId,
pub parent_span_id: Option<SpanId>,
pub name: String,
pub provider: Provider,
pub model: String,
pub input: LlmInput,
pub output: Option<LlmOutput>,
pub token_usage: Option<TokenUsage>,
pub cost: Option<Cost>,
pub latency: Latency,
pub metadata: Metadata,
pub status: SpanStatus,
pub attributes: HashMap<String, Value>,
pub events: Vec<SpanEvent>,
}Expand description
Represents a single LLM operation (request/response) as an OpenTelemetry span.
Fields§
§span_id: SpanIdUnique span identifier
trace_id: TraceIdTrace identifier this span belongs to
parent_span_id: Option<SpanId>Parent span identifier (if part of a chain)
name: StringSpan name/operation type
provider: ProviderLLM provider
model: StringModel name
input: LlmInputRequest input (prompt)
output: Option<LlmOutput>Response output
token_usage: Option<TokenUsage>Token usage statistics
cost: Option<Cost>Cost information
latency: LatencyLatency metrics
metadata: MetadataMetadata and tags
status: SpanStatusSpan status
attributes: HashMap<String, Value>OpenTelemetry attributes
events: Vec<SpanEvent>Events recorded during span
Implementations§
Source§impl LlmSpan
impl LlmSpan
Sourcepub fn builder() -> LlmSpanBuilder
pub fn builder() -> LlmSpanBuilder
Create a new LLM span builder.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if the span represents a successful operation.
Sourcepub fn total_tokens(&self) -> Option<u32>
pub fn total_tokens(&self) -> Option<u32>
Get total tokens used (if available).
Sourcepub fn total_cost_usd(&self) -> Option<f64>
pub fn total_cost_usd(&self) -> Option<f64>
Get total cost in USD (if available).
Sourcepub fn duration_ms(&self) -> u64
pub fn duration_ms(&self) -> u64
Get duration in milliseconds.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LlmSpan
impl<'de> Deserialize<'de> for LlmSpan
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LlmSpan
impl RefUnwindSafe for LlmSpan
impl Send for LlmSpan
impl Sync for LlmSpan
impl Unpin for LlmSpan
impl UnwindSafe for LlmSpan
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