reminder-bot/src/metrics.rs
jude de4ecf8dd6 QoL
* Made todo added responses ephemeral if /settings ephemeral is on
* Enabled systemd watchdog
* Move metrics to rocket
2024-06-04 18:40:49 +01:00

27 lines
1.1 KiB
Rust

use lazy_static::lazy_static;
use prometheus::{IntCounterVec, Opts, Registry};
lazy_static! {
pub static ref REGISTRY: Registry = Registry::new();
pub static ref REQUEST_COUNTER: IntCounterVec =
IntCounterVec::new(Opts::new("requests", "Web requests"), &["method", "status", "route"])
.unwrap();
pub static ref REMINDER_COUNTER: IntCounterVec =
IntCounterVec::new(Opts::new("reminders_sent", "Reminders sent"), &["id", "channel"])
.unwrap();
pub static ref REMINDER_FAIL_COUNTER: IntCounterVec = IntCounterVec::new(
Opts::new("reminders_failed", "Reminders failed"),
&["id", "channel", "error"]
)
.unwrap();
pub static ref COMMAND_COUNTER: IntCounterVec =
IntCounterVec::new(Opts::new("commands", "Commands used"), &["command"]).unwrap();
}
pub fn init_metrics() {
REGISTRY.register(Box::new(REQUEST_COUNTER.clone())).unwrap();
REGISTRY.register(Box::new(REMINDER_COUNTER.clone())).unwrap();
REGISTRY.register(Box::new(REMINDER_FAIL_COUNTER.clone())).unwrap();
REGISTRY.register(Box::new(COMMAND_COUNTER.clone())).unwrap();
}