pub struct Stats { /* private fields */ }Expand description
Top-level stats aggregator. Cheap to clone (Arc inside). One instance per
relay; sessions get tier-scoped handles via Stats::tier.
Implementations§
Source§impl Stats
impl Stats
Sourcepub fn new(
prefix: impl Into<PathOwned>,
levels: u32,
node: impl Into<Option<String>>,
origin: OriginProducer,
) -> Self
pub fn new( prefix: impl Into<PathOwned>, levels: u32, node: impl Into<Option<String>>, origin: OriginProducer, ) -> Self
Build a new stats aggregator.
prefixis the top-level path under which stats are published, e.g..stats. The full advertised path is<prefix>/prefix/<level-path>/<node>(or<prefix>/prefix/<level-path>whennodeisNone).levelsis the maximum segment depth stats are bucketed by, which caps the number of aggregation buckets per broadcast.0disables stats entirely (no buckets, including no root bucket).1produces the root bucket plus a per-first-segment bucket.2adds a per-second-segment bucket, and so on. A broadcast within the configured depth also gets its own dedicated bucket; broadcasts deeper thanlevelsare truncated.nodedisambiguates broadcasts published by different relays into a shared cluster origin. Set this on every node in multi-relay deployments.Noneomits the suffix, which is fine for single-relay deployments.originis theOriginProducerthat receivespublish_broadcastcalls for each stats broadcast.
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
A no-op aggregator. Counter bumps are silently dropped and no snapshot
task is ever spawned. Use this when stats are disabled so call sites
can hold a Stats (or StatsHandle) unconditionally.
Sourcepub fn tier(&self, tier: Tier) -> StatsHandle
pub fn tier(&self, tier: Tier) -> StatsHandle
Returns a tier-scoped handle. Bumps through this handle land in the tier’s counters.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stats
impl RefUnwindSafe for Stats
impl Send for Stats
impl Sync for Stats
impl Unpin for Stats
impl UnsafeUnpin for Stats
impl UnwindSafe for Stats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more