pub struct Producer { /* private fields */ }Expand description
Publishes a Registry’s counters as stats broadcasts. Cheap to clone.
Producer::new builds the registry itself (wiring the config’s prefix as
its exclude prefix) and spawns the publish task; hand sessions tier-scoped
handles via Registry::tier on Producer::registry. The task drains
the registry every interval and writes a frame per changed track, running
until the last Producer clone is dropped.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn new(config: ProducerConfig) -> Self
pub fn new(config: ProducerConfig) -> Self
Build a producer from config.
When config has an origin, this spawns the publish task immediately
and announces the stats broadcast; the task runs until the last
Producer clone is dropped. With no origin the producer is a no-op
(its registry is disabled, nothing is published) and no task spawns, so
it’s safe to build outside an async runtime.
Sourcepub fn registry(&self) -> &Registry
pub fn registry(&self) -> &Registry
The registry this producer drains. Hand sessions tier-scoped handles via
Registry::tier; read node totals back with Registry::snapshot.
Disabled (all bumps no-op) for a no-op producer.