pub trait Observer:
Send
+ Sync
+ 'static {
// Required methods
fn record_event(&self, event: &ObserverEvent);
fn record_metric(&self, metric: &ObserverMetric);
fn name(&self) -> &str;
fn as_any(&self) -> &dyn Any;
// Provided method
fn flush(&self) { ... }
}Expand description
Core observability trait for recording agent runtime telemetry.
Implement this trait to integrate with any monitoring backend (structured
logging, Prometheus, OpenTelemetry, etc.). The agent runtime holds one or
more Observer instances and calls record_event
and record_metric at key lifecycle points.
Implementations must be Send + Sync + 'static because the observer is
shared across async tasks via Arc.
Required Methods§
Sourcefn record_event(&self, event: &ObserverEvent)
fn record_event(&self, event: &ObserverEvent)
Record a discrete lifecycle event.
Called synchronously on the hot path; implementations should avoid blocking I/O. Buffer events internally and flush asynchronously when possible.
Sourcefn record_metric(&self, metric: &ObserverMetric)
fn record_metric(&self, metric: &ObserverMetric)
Record a numeric metric sample.
Called synchronously; same non-blocking guidance as
record_event.