pub struct MetricsLogObserver { /* private fields */ }Expand description
Collects (and tracing-logs) every MetricsData flowing on
Frame::Metrics — a pure, network-free metrics observer. Mirrors pipecat’s
MetricsLogObserver: it watches the push hook, de-dupes by frame id, and
records each metric with its timestamp so tests (and metric exporters) can
read TTFB/RTF/processing/usage semantics without a live sink.
“RTF” (real-time factor) is derived, not a first-class metric: it is
processing_seconds / audio_seconds for a stage that reports both — see
MetricsLogObserver::real_time_factor.
Implementations§
Source§impl MetricsLogObserver
impl MetricsLogObserver
Sourcepub fn metrics(&self) -> Vec<ObservedMetric>
pub fn metrics(&self) -> Vec<ObservedMetric>
Every metric observed so far, in observation order.
Sourcepub fn ttfb_seconds(&self, processor: &str) -> Option<f64>
pub fn ttfb_seconds(&self, processor: &str) -> Option<f64>
The most-recent TTFB (seconds) reported by processor, if any. TTFB is
the user-stop → first-output latency a service measures via
Link::start_ttfb /
Link::stop_ttfb.
Sourcepub fn processing_seconds(&self, processor: &str) -> Option<f64>
pub fn processing_seconds(&self, processor: &str) -> Option<f64>
The most-recent processing time (seconds) reported by processor.
Sourcepub fn real_time_factor(
&self,
processor: &str,
audio_seconds: f64,
) -> Option<f64>
pub fn real_time_factor( &self, processor: &str, audio_seconds: f64, ) -> Option<f64>
Real-time factor for processor: its last processing-time divided by
audio_seconds of audio it processed. RTF < 1 ⇒ faster than real time.
Returns None if no processing metric was seen or audio_seconds == 0.
Sourcepub fn total_llm_tokens(&self) -> u64
pub fn total_llm_tokens(&self) -> u64
Total LLM tokens summed across every LlmUsage metric seen.
Trait Implementations§
Source§impl Default for MetricsLogObserver
impl Default for MetricsLogObserver
Source§impl FrameObserver for MetricsLogObserver
impl FrameObserver for MetricsLogObserver
Source§fn on_push<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
e: &'life1 FramePushEvent<'life2>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_push<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
e: &'life1 FramePushEvent<'life2>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
base_observer.py:91).Source§fn on_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_e: &'life1 FrameEvent<'life2>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_process<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_e: &'life1 FrameEvent<'life2>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
base_observer.py:79).