From 2bcedc685df371777779198e390eabb52ad89f12 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 20 Apr 2024 04:05:11 +0000 Subject: [PATCH] metrics: rename `heartbeat_token_count` into `heartbeat_tokens` Fix warning from `promtool check metrics`: heartbeat_token_count non-histogram and non-summary metrics should not have "_count" suffix --- src/metrics.rs | 10 +++++----- src/notifier.rs | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/metrics.rs b/src/metrics.rs index fb26cfd..e48166f 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -29,7 +29,7 @@ pub struct Metrics { pub heartbeat_registrations_total: Counter, /// Number of tokens registered for heartbeat notifications. - pub heartbeat_token_count: Gauge, + pub heartbeat_tokens: Gauge, } impl Metrics { @@ -57,11 +57,11 @@ impl Metrics { heartbeat_registrations_total.clone(), ); - let heartbeat_token_count = Gauge::::default(); + let heartbeat_tokens = Gauge::::default(); registry.register( - "heartbeat_token_count", + "heartbeat_tokens", "Number of tokens registered for heartbeat notifications", - heartbeat_token_count.clone(), + heartbeat_tokens.clone(), ); Self { @@ -69,7 +69,7 @@ impl Metrics { direct_notifications_total, heartbeat_notifications_total, heartbeat_registrations_total, - heartbeat_token_count, + heartbeat_tokens, } } } diff --git a/src/notifier.rs b/src/notifier.rs index b8c88fa..2d17f57 100644 --- a/src/notifier.rs +++ b/src/notifier.rs @@ -24,9 +24,7 @@ pub async fn start(state: State, interval: std::time::Duration) -> Result<()> { ); loop { - metrics - .heartbeat_token_count - .set(schedule.token_count() as i64); + metrics.heartbeat_tokens.set(schedule.token_count() as i64); let Some((timestamp, token)) = schedule.pop()? else { info!("No tokens to notify, sleeping for a minute.");