pub struct Registry { /* private fields */ }Expand description
Wraps prometheus::Registry with an embedded Filter so that
register_*_with_registry! macros can decide whether a metric is exposed.
Metrics registered through the wrapper macros join the inner registry
wrapped in a private collector type, which consults the filter on every
collect.
Exposure changes need no bookkeeping here: the next gather simply sees the
new filter.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a registry whose filter honours the METRICS_FILTER env var
(permissive when unset).
Sourcepub fn new_custom(
prefix: Option<String>,
labels: Option<HashMap<String, String>>,
filter: Option<Arc<Filter>>,
) -> Result<Self>
pub fn new_custom( prefix: Option<String>, labels: Option<HashMap<String, String>>, filter: Option<Arc<Filter>>, ) -> Result<Self>
Creates a custom-prefixed registry.
Sourcepub fn filter(&self) -> Arc<Filter>
pub fn filter(&self) -> Arc<Filter>
Returns the registry’s filter, so related registries can be built to
share it via Registry::new_custom.
Sourcepub fn register_filtered<C>(
&self,
name: &str,
module: &str,
level: MetricLevel,
collector: C,
) -> Result<C>
pub fn register_filtered<C>( &self, name: &str, module: &str, level: MetricLevel, collector: C, ) -> Result<C>
Used by the wrapper macros: registers collector wrapped in a private
collector type, so the filter in effect at each gather decides
whether the metric is exposed. Duplicate registrations are rejected by
the inner registry’s descriptor check, hidden or not.
pub fn register(&self, c: Box<dyn Collector>) -> Result<()>
pub fn unregister(&self, c: Box<dyn Collector>) -> Result<()>
Sourcepub fn gather(&self) -> Vec<MetricFamily>
pub fn gather(&self) -> Vec<MetricFamily>
Gathers the registry’s metric families.