Add IDs to metrics
This commit is contained in:
@ -9,10 +9,11 @@ lazy_static! {
|
||||
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"), &["channel"]).unwrap();
|
||||
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"),
|
||||
&["channel", "error"]
|
||||
&["id", "channel", "error"]
|
||||
)
|
||||
.unwrap();
|
||||
pub static ref COMMAND_COUNTER: IntCounterVec =
|
||||
|
@ -446,13 +446,22 @@ impl Reminder {
|
||||
};
|
||||
|
||||
REMINDER_FAIL_COUNTER
|
||||
.with_label_values(&[self.channel_id.to_string().as_str(), &message])
|
||||
.inc();
|
||||
.get_metric_with_label_values(&[
|
||||
self.id.to_string().as_str(),
|
||||
self.channel_id.to_string().as_str(),
|
||||
&message,
|
||||
])
|
||||
.map_or_else(|e| warn!("Couldn't count failed reminder: {:?}", e), |c| c.inc());
|
||||
error!("[Reminder {}] {}", self.id, message);
|
||||
}
|
||||
|
||||
async fn log_success(&self) {
|
||||
REMINDER_COUNTER.with_label_values(&[self.channel_id.to_string().as_str()]).inc()
|
||||
REMINDER_COUNTER
|
||||
.get_metric_with_label_values(&[
|
||||
self.id.to_string().as_str(),
|
||||
self.channel_id.to_string().as_str(),
|
||||
])
|
||||
.map_or_else(|e| warn!("Couldn't count sent reminder: {:?}", e), |c| c.inc());
|
||||
}
|
||||
|
||||
async fn set_sent(&self, pool: impl Executor<'_, Database = Database> + Copy) {
|
||||
|
Reference in New Issue
Block a user