pub struct Registry { /* private fields */ }
Expand description
A struct for registering Prometheus collectors, collecting their metrics, and gathering
them into MetricFamilies
for exposition.
Implementations§
§impl Registry
impl Registry
pub fn new_custom(
prefix: Option<String>,
labels: Option<HashMap<String, String>>,
) -> Result<Registry, Error>
pub fn new_custom( prefix: Option<String>, labels: Option<HashMap<String, String>>, ) -> Result<Registry, Error>
Create a new registry, with optional custom prefix and labels.
pub fn register(&self, c: Box<dyn Collector>) -> Result<(), Error>
pub fn register(&self, c: Box<dyn Collector>) -> 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.
pub fn unregister(&self, c: Box<dyn Collector>) -> Result<(), Error>
pub fn unregister(&self, c: Box<dyn Collector>) -> Result<(), Error>
unregister
unregisters the [Collector
] that equals the [Collector
] passed
in as an argument. (Two Collectors are considered equal if their
Describe method yields the same set of descriptors.) The function
returns error when the [Collector
] is not registered.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Registry
impl !RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl !UnwindSafe for Registry
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)