(&mut self, name: String, m: MetricEvent, labels: HashMap<String, String>)
| 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. |
no test coverage detected