pub struct Registry { /* private fields */ }Expand description
Counter collection, re-exported from moq_net::stats so stats consumers
can depend on this crate alone.
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() -> Registry
pub fn disabled() -> Registry
Build a no-op registry: every handle is empty and all bumps are dropped.
Sourcepub fn exclude(&self) -> &Patterns
pub fn exclude(&self) -> &Patterns
The excluded patterns. See Config::exclude.
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 totals (what a /metrics-style scrape wants) and never prunes.
Sourcepub fn report(&self, report: &mut Report)
pub fn report(&self, report: &mut Report)
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)
session gauge. Entries no guard references anymore are then dropped
(their final values are still in the report, so a publisher draining on
an interval emits 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.