#[non_exhaustive]pub struct AgentTrace {
pub id: String,
pub name: String,
pub parent_id: Option<String>,
pub start_time: u64,
pub end_time: Option<u64>,
pub duration: u64,
pub children: Vec<AgentTrace>,
pub metadata: JsonObject,
pub message: Option<Message>,
}Expand description
A node in the local timing tree of an invocation (AgentTrace).
Collected whether or not OpenTelemetry is configured. Serializes with null for an absent
parent, end time or message.
use strands::telemetry::AgentTrace;
let mut cycle = AgentTrace::new("Cycle 1", 1_000);
cycle.add_child(AgentTrace::new("stream_messages", 1_001)).end(1_100);
cycle.end(1_200);
assert_eq!(cycle.children[0].parent_id.as_deref(), Some(cycle.id.as_str()));
assert_eq!(cycle.duration, 200);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringUnique identifier (a UUID).
name: StringDisplay name, such as Cycle 1 or Tool: calc.
parent_id: Option<String>The parent trace’s id; None for a root trace.
start_time: u64Start time in milliseconds since the Unix epoch.
end_time: Option<u64>End time in milliseconds since the Unix epoch; None until the trace ends.
duration: u64Duration in milliseconds.
children: Vec<AgentTrace>Nested traces.
metadata: JsonObjectString metadata such as cycleId, toolUseId and toolName.
message: Option<Message>The message associated with the trace, such as the model output.
Implementations§
Source§impl AgentTrace
impl AgentTrace
Sourcepub fn new(name: impl Into<String>, start_time: u64) -> Self
pub fn new(name: impl Into<String>, start_time: u64) -> Self
Creates a root trace that starts at start_time (milliseconds since the epoch).
Sourcepub fn add_child(&mut self, child: AgentTrace) -> &mut AgentTrace
pub fn add_child(&mut self, child: AgentTrace) -> &mut AgentTrace
Nests child under this trace and returns it.
Trait Implementations§
Source§impl Clone for AgentTrace
impl Clone for AgentTrace
Source§impl Debug for AgentTrace
impl Debug for AgentTrace
Source§impl<'de> Deserialize<'de> for AgentTrace
impl<'de> Deserialize<'de> for AgentTrace
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
Source§impl PartialEq for AgentTrace
impl PartialEq for AgentTrace
Source§impl Serialize for AgentTrace
impl Serialize for AgentTrace
impl StructuralPartialEq for AgentTrace
Auto Trait Implementations§
impl !RefUnwindSafe for AgentTrace
impl !UnwindSafe for AgentTrace
impl Freeze for AgentTrace
impl Send for AgentTrace
impl Sync for AgentTrace
impl Unpin for AgentTrace
impl UnsafeUnpin for AgentTrace
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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.