pub trait TracerEvent: Send + Sync {
// Required methods
fn timestamp(&self) -> f64;
fn correlation_id(&self) -> &str;
fn source(&self) -> &str;
fn printable_summary(&self) -> String;
// Provided method
fn as_any(&self) -> Option<&dyn Any> { ... }
}Expand description
Base trait for all tracer events
Tracer events are used to track system interactions for observability purposes. They are distinct from regular events which are used for agent communication.
Required Methods§
Sourcefn correlation_id(&self) -> &str
fn correlation_id(&self) -> &str
Get the correlation ID for tracing related events
Sourcefn printable_summary(&self) -> String
fn printable_summary(&self) -> String
Get a formatted string summary of the event
Provided Methods§
Sourcefn as_any(&self) -> Option<&dyn Any>
fn as_any(&self) -> Option<&dyn Any>
Expose the concrete event for downcasting, when the event type allows it.
The built-in events return Some(self), so an crate::tracer::EventCallback
can read typed fields, for example the evidence on an
LlmResponseTracerEvent:
use mojentic::tracer::{LlmResponseTracerEvent, TracerEvent};
fn finish_reason(event: &dyn TracerEvent) -> Option<String> {
event
.as_any()?
.downcast_ref::<LlmResponseTracerEvent>()?
.evidence
.finish_reason
.clone()
}Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".