nv_core/metrics.rs
1//! Metrics helpers for per-feed instrumentation.
2//!
3//! The library uses the `tracing` crate for structured logging and depends
4//! on user-configured subscribers for export. This module provides helpers
5//! for per-feed metric recording and snapshot types.
6//!
7//! The runtime records and exposes per-feed metrics through
8//! [`FeedMetrics`] snapshots available via `FeedHandle::metrics()`.
9
10use crate::id::FeedId;
11
12/// A snapshot of per-feed metrics at a point in time.
13///
14/// Returned by `FeedHandle::metrics()`.
15#[derive(Debug, Clone, Copy)]
16pub struct FeedMetrics {
17 /// Which feed these metrics belong to.
18 pub feed_id: FeedId,
19 /// Total frames received from the source.
20 pub frames_received: u64,
21 /// Frames dropped due to backpressure.
22 pub frames_dropped: u64,
23 /// Frames successfully processed through all stages.
24 pub frames_processed: u64,
25 /// Number of active tracks in the temporal store.
26 pub tracks_active: u64,
27 /// Current view epoch value.
28 pub view_epoch: u64,
29 /// Number of feed restarts.
30 pub restarts: u32,
31}
32
33/// Per-stage metrics snapshot, included in [`StageContext`](crate) for
34/// stages that want to adapt behavior based on their own performance.
35#[derive(Debug, Clone, Copy)]
36pub struct StageMetrics {
37 /// Cumulative frame count processed by this stage.
38 pub frames_processed: u64,
39 /// Cumulative error count for this stage.
40 pub errors: u64,
41}