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

Method gauge_mut

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

Returns a gauge metric with the given name and helper message that explains what the gauge is measuring or tracking.

(&mut self, name: &str, helper_message: &str)

Source from the content-addressed store, hash-verified

152 /// Returns a gauge metric with the given name and helper message that explains what
153 /// the gauge is measuring or tracking.
154 pub fn gauge_mut(&mut self, name: &str, helper_message: &str) -> &mut Gauge {
155 match self.metric_gauges.entry(name.to_string()) {
156 Entry::Occupied(entry) => entry.into_mut(),
157 Entry::Vacant(entry) => {
158 let gauge = Gauge::with_opts(Opts::new(
159 format!("{}_{}", self.service_name, name),
160 helper_message,
161 ))
162 .unwrap();
163
164 self.registry.register(Box::new(gauge.clone())).unwrap();
165
166 entry.insert(gauge)
167 }
168 }
169 }
170
171 /// Removes a gauge metric with the given name.
172 pub fn remove_gauge(&mut self, name: &str) {

Callers 10

metricsMethod · 0.80
metricsMethod · 0.80
getMethod · 0.80
setMethod · 0.80
incMethod · 0.80
decMethod · 0.80
test_metrics_registryFunction · 0.80
test_remove_gaugeFunction · 0.80

Calls 2

registerMethod · 0.45
insertMethod · 0.45

Tested by 4

test_metrics_registryFunction · 0.64
test_remove_gaugeFunction · 0.64