diff --git a/src/metrics/family.rs b/src/metrics/family.rs index 3b70eeb9..066ecacf 100644 --- a/src/metrics/family.rs +++ b/src/metrics/family.rs @@ -248,6 +248,23 @@ impl> Family, Counter>::default(); + /// + /// if let Some(metric) = family.get(&vec![("method".to_owned(), "GET".to_owned())]) { + /// metric.inc(); + /// }; + /// ``` + pub fn get(&self, label_set: &S) -> Option> { + RwLockReadGuard::try_map(self.metrics.read(), |metrics| metrics.get(label_set)).ok() + } + /// Remove a label set from the metric family. /// /// Returns a bool indicating if a label set was removed or not.