diff --git a/src/metrics.rs b/src/metrics.rs index 5c2358b..219b30c 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -60,21 +60,6 @@ impl Metrics { heartbeat_token_count, } } - - /// Counts direct notification. - pub fn inc_direct_notification(&self) { - self.direct_notifications_total.inc(); - } - - /// Counts heartbeat notification. - pub fn inc_heartbeat_notification(&self) { - self.heartbeat_notifications_total.inc(); - } - - /// Sets number of tokens registered for heartbeat notifications. - pub fn set_heartbeat_token_count(&self, value: usize) { - self.heartbeat_token_count.set(value as i64); - } } type State = Arc; diff --git a/src/notifier.rs b/src/notifier.rs index 9df93ac..f1a175b 100644 --- a/src/notifier.rs +++ b/src/notifier.rs @@ -48,7 +48,7 @@ async fn wakeup( .collect::>(); info!("sending notifications to {} devices", tokens.len()); - metrics.set_heartbeat_token_count(tokens.len()); + metrics.heartbeat_token_count.set(tokens.len() as i64); for key_device_token in tokens { info!("notify: {}", key_device_token); @@ -82,7 +82,7 @@ async fn wakeup( Ok(res) => match res.code { 200 => { info!("delivered notification for {}", device_token); - metrics.inc_heartbeat_notification(); + metrics.heartbeat_notifications_total.inc(); } _ => { warn!("unexpected status: {:?}", res); diff --git a/src/server.rs b/src/server.rs index 2f358dc..3e05910 100644 --- a/src/server.rs +++ b/src/server.rs @@ -73,7 +73,7 @@ async fn notify_device(mut req: tide::Request) -> tide::Result { info!("delivered notification for {}", device_token); - req.state().metrics().inc_direct_notification(); + req.state().metrics().direct_notifications_total.inc(); } _ => { warn!("unexpected status: {:?}", res);