pub struct TracerSystem { /* private fields */ }Expand description
Central system for capturing and querying tracer events
The TracerSystem is responsible for recording events related to LLM calls, tool usage, and agent interactions, providing a way to trace through the major events of the system.
Implementations§
Source§impl TracerSystem
impl TracerSystem
Sourcepub fn new(event_store: Option<Arc<EventStore>>, enabled: bool) -> Self
pub fn new(event_store: Option<Arc<EventStore>>, enabled: bool) -> Self
Create a new tracer system
§Arguments
event_store- Optional event store to use. If None, a new one will be created.enabled- Whether the tracer system is enabled (default: true)
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the tracer is enabled
Sourcepub fn record_event(&self, event: Box<dyn TracerEvent>)
pub fn record_event(&self, event: Box<dyn TracerEvent>)
Sourcepub fn record_llm_call(
&self,
model: impl Into<String>,
messages: Vec<HashMap<String, Value>>,
temperature: f64,
tools: Option<Vec<HashMap<String, Value>>>,
source: impl Into<String>,
correlation_id: impl Into<String>,
)
pub fn record_llm_call( &self, model: impl Into<String>, messages: Vec<HashMap<String, Value>>, temperature: f64, tools: Option<Vec<HashMap<String, Value>>>, source: impl Into<String>, correlation_id: impl Into<String>, )
Record an LLM call event
§Arguments
model- The name of the LLM model being calledmessages- The messages sent to the LLM (simplified representation)temperature- The temperature setting for the LLM calltools- The tools available to the LLM, if anysource- The source of the eventcorrelation_id- UUID string for tracing related events
Sourcepub fn record_llm_response(
&self,
model: impl Into<String>,
content: impl Into<String>,
tool_calls: Option<Vec<HashMap<String, Value>>>,
call_duration_ms: Option<f64>,
source: impl Into<String>,
correlation_id: impl Into<String>,
)
pub fn record_llm_response( &self, model: impl Into<String>, content: impl Into<String>, tool_calls: Option<Vec<HashMap<String, Value>>>, call_duration_ms: Option<f64>, source: impl Into<String>, correlation_id: impl Into<String>, )
Record an LLM response event
§Arguments
model- The name of the LLM model that respondedcontent- The content of the LLM responsetool_calls- Any tool calls made by the LLM in its responsecall_duration_ms- The duration of the LLM call in millisecondssource- The source of the eventcorrelation_id- UUID string for tracing related events
Sourcepub fn record_tool_call(
&self,
tool_name: impl Into<String>,
arguments: HashMap<String, Value>,
result: Value,
caller: Option<String>,
call_duration_ms: Option<f64>,
source: impl Into<String>,
correlation_id: impl Into<String>,
)
pub fn record_tool_call( &self, tool_name: impl Into<String>, arguments: HashMap<String, Value>, result: Value, caller: Option<String>, call_duration_ms: Option<f64>, source: impl Into<String>, correlation_id: impl Into<String>, )
Record a tool call event
§Arguments
tool_name- The name of the tool being calledarguments- The arguments provided to the toolresult- The result returned by the toolcaller- The name of the agent or component calling the toolcall_duration_ms- The duration of the tool call in millisecondssource- The source of the eventcorrelation_id- UUID string for tracing related events
Sourcepub fn record_agent_interaction(
&self,
from_agent: impl Into<String>,
to_agent: impl Into<String>,
event_type: impl Into<String>,
event_id: Option<String>,
source: impl Into<String>,
correlation_id: impl Into<String>,
)
pub fn record_agent_interaction( &self, from_agent: impl Into<String>, to_agent: impl Into<String>, event_type: impl Into<String>, event_id: Option<String>, source: impl Into<String>, correlation_id: impl Into<String>, )
Record an agent interaction event
§Arguments
from_agent- The name of the agent sending the eventto_agent- The name of the agent receiving the eventevent_type- The type of event being processedevent_id- A unique identifier for the eventsource- The source of the eventcorrelation_id- UUID string for tracing related events
Sourcepub fn get_event_summaries(
&self,
start_time: Option<f64>,
end_time: Option<f64>,
filter_func: Option<&dyn EventFilterFn>,
) -> Vec<String>
pub fn get_event_summaries( &self, start_time: Option<f64>, end_time: Option<f64>, filter_func: Option<&dyn EventFilterFn>, ) -> Vec<String>
Sourcepub fn get_last_n_summaries(
&self,
n: usize,
filter_func: Option<&dyn EventFilterFn>,
) -> Vec<String>
pub fn get_last_n_summaries( &self, n: usize, filter_func: Option<&dyn EventFilterFn>, ) -> Vec<String>
Sourcepub fn count_events(
&self,
start_time: Option<f64>,
end_time: Option<f64>,
filter_func: Option<&dyn EventFilterFn>,
) -> usize
pub fn count_events( &self, start_time: Option<f64>, end_time: Option<f64>, filter_func: Option<&dyn EventFilterFn>, ) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TracerSystem
impl !RefUnwindSafe for TracerSystem
impl Send for TracerSystem
impl Sync for TracerSystem
impl Unpin for TracerSystem
impl !UnwindSafe for TracerSystem
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