Returns a counter metric with the given name and helper message that explains what the counter is measuring or tracking.
(&mut self, name: &str, helper_message: &str)
| 90 | /// Returns a counter metric with the given name and helper message that explains what |
| 91 | /// the counter is measuring or tracking. |
| 92 | pub fn counter_mut(&mut self, name: &str, helper_message: &str) -> &mut Counter { |
| 93 | match self.metric_counters.entry(name.to_string()) { |
| 94 | Entry::Occupied(entry) => entry.into_mut(), |
| 95 | Entry::Vacant(entry) => { |
| 96 | let counter = Counter::with_opts(Opts::new( |
| 97 | format!("{}_{}", self.service_name, name), |
| 98 | helper_message, |
| 99 | )) |
| 100 | .unwrap(); |
| 101 | |
| 102 | self.registry.register(Box::new(counter.clone())).unwrap(); |
| 103 | |
| 104 | entry.insert(counter) |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /// Removes a counter metric with the given name. |
| 110 | pub fn remove_counter(&mut self, name: &str) { |