Expand description
Tracer system for observability and debugging
The tracer system provides comprehensive observability into LLM interactions, tool executions, and agent communications. It records events with timestamps and correlation IDs, enabling detailed debugging and monitoring.
§Architecture
The tracer system consists of several key components:
- TracerEvent: Base trait for all event types with timestamps and correlation IDs
- EventStore: Thread-safe storage for events with callbacks and filtering
- TracerSystem: Coordination layer providing convenience methods for recording events
- NullTracer: Null object pattern for when tracing is disabled
§Event Types
- LlmCallTracerEvent: Records LLM calls with model, messages, temperature, and tools
- LlmResponseTracerEvent: Records LLM responses with content, tool calls, and duration
- ToolCallTracerEvent: Records tool executions with arguments, results, and duration
- AgentInteractionTracerEvent: Records agent-to-agent communications
§Usage Example
ⓘ
use mojentic::tracer::{TracerSystem, LlmCallTracerEvent};
use std::collections::HashMap;
// Create a tracer system
let tracer = TracerSystem::default();
// Record an LLM call
tracer.record_llm_call(
"llama3.2",
vec![],
0.7,
None,
"my_agent",
"correlation-123"
);
// Query events
let events = tracer.get_events(None, None, None);
for event in events {
println!("{}", event.printable_summary());
}§Correlation IDs
Correlation IDs are UUIDs that are copied from cause-to-effect across the system, enabling you to trace all events related to a single request or operation. This creates a complete audit trail for debugging and observability.
Re-exports§
pub use event_store::EventCallback;pub use event_store::EventStore;pub use null_tracer::NullTracer;pub use tracer_events::AgentInteractionTracerEvent;pub use tracer_events::EventFilterFn;pub use tracer_events::LlmCallTracerEvent;pub use tracer_events::LlmResponseTracerEvent;pub use tracer_events::ToolCallTracerEvent;pub use tracer_events::TracerEvent;pub use tracer_system::TracerSystem;
Modules§
- event_
store - Event storage with callbacks and filtering
- null_
tracer - Null tracer implementation following the Null Object Pattern
- tracer_
events - Tracer event types for tracking system interactions
- tracer_
system - Tracer system for coordinating tracer events