pub struct Registry { /* private fields */ }Expand description
Counter collection registry. Cheap to clone (Arc inside for the shared
state). One instance per relay; sessions get tier-scoped handles via
Registry::tier. The moq-stats crate drains it with
Registry::report to publish the counters as MoQ broadcasts.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
Build a no-op registry: every handle is empty and all bumps are dropped.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether this registry collects counters.
Sourcepub fn tier(&self, tier: Tier) -> Handle
pub fn tier(&self, tier: Tier) -> Handle
Returns a tier-scoped handle. Bumps through this handle land in the tier’s counters.
Sourcepub fn snapshot(&self) -> Snapshot
pub fn snapshot(&self) -> Snapshot
Take a host-level Snapshot: every counter summed across all
tracked broadcasts, split by tier and role, plus per-tier session
presence. Briefly takes the entry then the session locks. Returns an
all-zero snapshot for a disabled registry.
Unlike Registry::report, this collapses per-broadcast detail into
node lifetime totals (what a /metrics-style scrape wants) and never prunes.
Retired entries remain in these totals after Self::report prunes them.
Sourcepub fn report(&self, report: &mut Report, now: Instant)
pub fn report(&self, report: &mut Report, now: Instant)
Refill report with the per-broadcast detail and prune dead entries.
Clears report, keeping its capacity so a caller draining on an
interval reuses one report instead of allocating per drain, then fills
every (broadcast, tier) traffic readout and every (tier, root, label)
session gauge. Entries no guard references anymore are dropped after
their final readout, which is marked closed, so a publisher draining on
an interval sees the closing readout exactly once. A pruned path that
sees traffic again restarts from zero; see the module docs on counter
resets. Leaves the report empty for a disabled registry.
now is the drain’s time, usually Instant::now, which dates each
session’s activity window.