pub struct Observation {Show 16 fields
pub id: Id,
pub trace_id: Id,
pub parent_observation_id: Option<Id>,
pub name: String,
pub observation_type: ObservationType,
pub start_time: DateTime<Utc>,
pub end_time: Option<DateTime<Utc>>,
pub input: Option<Value>,
pub output: Option<Value>,
pub metadata: Value,
pub level: ObservationLevel,
pub status_message: Option<String>,
pub model: Option<String>,
pub model_parameters: Option<Value>,
pub usage: Option<TokenUsage>,
pub cost: Option<f64>,
}Expand description
Observation represents a single unit of work within a trace.
Observations form a tree structure via parent_observation_id.
A graph invocation creates observations for each superstep,
node execution, LLM call, and tool call.
Fields§
§id: IdUnique observation identifier.
trace_id: IdParent trace identifier.
parent_observation_id: Option<Id>Parent observation identifier for nesting (None = top-level).
name: StringHuman-readable name (node name, model name, tool name).
observation_type: ObservationTypeType of observation.
start_time: DateTime<Utc>Observation start timestamp.
end_time: Option<DateTime<Utc>>Observation end timestamp.
input: Option<Value>Input data (prompt messages, tool arguments, etc.).
output: Option<Value>Output data (completion text, tool result, etc.).
metadata: ValueArbitrary key-value metadata.
level: ObservationLevelSeverity level.
status_message: Option<String>Human-readable status message (error details, etc.).
model: Option<String>LLM model name (e.g., “claude-sonnet-4-20250514”).
model_parameters: Option<Value>Model parameters (temperature, max_tokens, etc.).
usage: Option<TokenUsage>Token usage statistics.
cost: Option<f64>Cost in USD for this call.
Implementations§
Source§impl Observation
impl Observation
Sourcepub fn generation(
trace_id: Id,
name: impl Into<String>,
model: impl Into<String>,
) -> Self
pub fn generation( trace_id: Id, name: impl Into<String>, model: impl Into<String>, ) -> Self
Create a new LLM generation observation.
Sourcepub fn tool_call(trace_id: Id, name: impl Into<String>) -> Self
pub fn tool_call(trace_id: Id, name: impl Into<String>) -> Self
Create a new tool call observation.
Sourcepub const fn with_parent(self, parent_id: Id) -> Self
pub const fn with_parent(self, parent_id: Id) -> Self
Set the parent observation for nesting.
Sourcepub fn complete(&mut self, output: Option<Value>)
pub fn complete(&mut self, output: Option<Value>)
Mark the observation as completed with optional output.
Sourcepub fn fail(&mut self, message: impl Into<String>)
pub fn fail(&mut self, message: impl Into<String>)
Mark the observation as failed with an error message.
Sourcepub fn duration_ms(&self) -> Option<u64>
pub fn duration_ms(&self) -> Option<u64>
Duration in milliseconds (if completed).
Trait Implementations§
Source§impl Clone for Observation
impl Clone for Observation
Source§fn clone(&self) -> Observation
fn clone(&self) -> Observation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Observation
impl Debug for Observation
Source§impl<'de> Deserialize<'de> for Observation
impl<'de> Deserialize<'de> for Observation
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>,
Auto Trait Implementations§
impl Freeze for Observation
impl RefUnwindSafe for Observation
impl Send for Observation
impl Sync for Observation
impl Unpin for Observation
impl UnsafeUnpin for Observation
impl UnwindSafe for Observation
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
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>
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 more