MCPcopy Create free account
hub / github.com/dfinity/orbit / counter_mut

Method counter_mut

libs/orbit-essentials/src/metrics.rs:92–107  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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) {

Callers 4

getMethod · 0.80
incMethod · 0.80
test_metrics_registryFunction · 0.80
test_remove_counterFunction · 0.80

Calls 2

registerMethod · 0.45
insertMethod · 0.45

Tested by 2

test_metrics_registryFunction · 0.64
test_remove_counterFunction · 0.64