pub struct ToolExecution {
pub id: String,
pub tool_name: String,
pub timestamp: DateTime<Utc>,
pub duration_ms: u64,
pub success: bool,
pub error: Option<String>,
pub tokens_used: Option<u64>,
pub session_id: Option<String>,
pub input: Option<Value>,
pub file_changes: Vec<FileChange>,
}Expand description
Telemetry record for one tool invocation.
Build one with ToolExecution::start at the top of your tool’s
execute() impl, then finalize it with ToolExecution::complete /
ToolExecution::fail before returning.
§Examples
use codetether_agent::telemetry::ToolExecution;
use serde_json::json;
let mut exec = ToolExecution::start("read", json!({"path": "foo.rs"}));
assert!(!exec.success);
exec.complete(true, 42);
assert!(exec.success);
assert_eq!(exec.duration_ms, 42);Fields§
§id: StringUnique id for cross-referencing with the audit log.
tool_name: StringRegistered tool name (e.g. "bash", "read").
timestamp: DateTime<Utc>When execution started.
duration_ms: u64Wall-clock duration in milliseconds.
success: booltrue iff the tool returned Ok.
error: Option<String>Error message when success is false.
tokens_used: Option<u64>Tokens attributed to this invocation, when known.
session_id: Option<String>Owning session’s UUID, when available.
input: Option<Value>Raw tool input as JSON.
file_changes: Vec<FileChange>Files the tool touched during this invocation.
Implementations§
Source§impl ToolExecution
impl ToolExecution
Sourcepub fn start(tool_name: &str, input: Value) -> Self
pub fn start(tool_name: &str, input: Value) -> Self
Start a new pending execution. success defaults to false until
explicitly completed.
Sourcepub fn add_file_change(&mut self, change: FileChange)
pub fn add_file_change(&mut self, change: FileChange)
Attach a FileChange the tool performed.
Sourcepub fn with_session(self, session_id: String) -> Self
pub fn with_session(self, session_id: String) -> Self
Builder-style: associate this execution with a session.
Sourcepub fn complete(&mut self, success: bool, duration_ms: u64)
pub fn complete(&mut self, success: bool, duration_ms: u64)
In-place finalizer — mutates an existing record.
Sourcepub fn complete_success(self, _output: String, duration: Duration) -> Self
pub fn complete_success(self, _output: String, duration: Duration) -> Self
Consuming finalizer for success. _output is accepted for API
compatibility and currently discarded.
Sourcepub fn complete_error(self, error: String, duration: Duration) -> Self
pub fn complete_error(self, error: String, duration: Duration) -> Self
Consuming finalizer for failure.
Trait Implementations§
Source§impl Clone for ToolExecution
impl Clone for ToolExecution
Source§fn clone(&self) -> ToolExecution
fn clone(&self) -> ToolExecution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolExecution
impl Debug for ToolExecution
Source§impl<'de> Deserialize<'de> for ToolExecution
impl<'de> Deserialize<'de> for ToolExecution
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 ToolExecution
impl RefUnwindSafe for ToolExecution
impl Send for ToolExecution
impl Sync for ToolExecution
impl Unpin for ToolExecution
impl UnsafeUnpin for ToolExecution
impl UnwindSafe for ToolExecution
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,
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 moreSource§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>
T in a tonic::Request