MCPcopy Create free account
hub / github.com/Botloader/botloader / handle_metric

Method handle_metric

components/scheduler/src/vm_session.rs:357–387  ·  view source on GitHub ↗
(&mut self, name: String, m: MetricEvent, labels: HashMap<String, String>)

Source from the content-addressed store, hash-verified

355 }
356
357 fn handle_metric(&mut self, name: String, m: MetricEvent, labels: HashMap<String, String>) {
358 let mut labels = labels
359 .into_iter()
360 .map(|(k, v)| metrics::Label::new(k, v))
361 .collect::<Vec<_>>();
362
363 if name != "dispatch_event_latency" {
364 labels.push(metrics::Label::new("guild_id", self.guild_id.to_string()));
365 }
366
367 match m {
368 MetricEvent::Gauge(action) => {
369 let handle = metrics::gauge!(name, labels);
370 match action {
371 scheduler_worker_rpc::GaugeEvent::Set(v) => handle.set(v),
372 scheduler_worker_rpc::GaugeEvent::Incr(v) => handle.increment(v),
373 }
374 }
375 MetricEvent::Counter(action) => {
376 let handle = metrics::counter!(name, labels);
377
378 match action {
379 scheduler_worker_rpc::CounterEvent::Incr(v) => handle.increment(v),
380 scheduler_worker_rpc::CounterEvent::Absolute(v) => handle.absolute(v),
381 }
382 }
383 MetricEvent::Histogram(action) => {
384 metrics::histogram!(name, labels).record(action);
385 }
386 }
387 }
388
389 /// Returns the worker to the pool with the vm still alive; the session
390 /// state stays on the handle so the vm can be resumed on a later claim.

Callers 1

handle_worker_msgMethod · 0.80

Calls 4

incrementMethod · 0.80
absoluteMethod · 0.80
recordMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected