pub struct Registry { /* private fields */ }Expand description
Wraps prometheus::Registry with an embedded Filter so that
register_*_with_registry! macros can decide at construction time whether
a metric should be active.
Metrics registered through the wrapper macros are recorded with their
module path and level, so Registry::gather can apply the filter’s
exposure directives to them.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a registry whose filter is resolved from 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 record(&self, name: &str, module: &str, level: MetricLevel)
pub fn record(&self, name: &str, module: &str, level: MetricLevel)
Used by the wrapper macros: records a registering metric’s module path
and level, so Registry::gather can apply the filter’s exposure
directives to it.
Sourcepub fn inner(&self) -> &Registry
pub fn inner(&self) -> &Registry
Returns the underlying prometheus::Registry for use inside wrapper
macros.
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, dropping those disabled by the filter’s exposure directives. Families not registered through the wrapper macros (e.g. direct collectors) always pass through.