Struct substrate_prometheus_endpoint::Registry
source · pub struct Registry { /* private fields */ }
Expand description
A struct for registering Prometheus collectors, collecting their metrics, and gathering
them into MetricFamilies
for exposition.
Implementations§
source§impl Registry
impl Registry
sourcepub fn new_custom(
prefix: Option<String>,
labels: Option<HashMap<String, String, RandomState>>
) -> Result<Registry, Error>
pub fn new_custom(
prefix: Option<String>,
labels: Option<HashMap<String, String, RandomState>>
) -> Result<Registry, Error>
Create a new registry, with optional custom prefix and labels.
sourcepub fn register(
&self,
c: Box<dyn Collector + 'static, Global>
) -> Result<(), Error>
pub fn register(
&self,
c: Box<dyn Collector + 'static, Global>
) -> Result<(), Error>
register
registers a new Collector
to be included in metrics
collection. It returns an error if the descriptors provided by the
Collector
are invalid or if they — in combination with descriptors of
already registered Collectors — do not fulfill the consistency and
uniqueness criteria described in the documentation of Desc
.
If the provided Collector
is equal to a Collector
already registered
(which includes the case of re-registering the same Collector
), the
AlreadyReg error returns.
sourcepub fn gather(&self) -> Vec<MetricFamily, Global>
pub fn gather(&self) -> Vec<MetricFamily, Global>
gather
calls the Collect method of the registered Collectors and then
gathers the collected metrics into a lexicographically sorted slice
of MetricFamily protobufs.