Skip to content

Commit

Permalink
metrics: rename heartbeat_token_count into heartbeat_tokens
Browse files Browse the repository at this point in the history
Fix warning from `promtool check metrics`:
  heartbeat_token_count non-histogram and non-summary metrics should not have "_count" suffix
  • Loading branch information
link2xt committed Apr 20, 2024
1 parent c8bd1bf commit 2bcedc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Metrics {
pub heartbeat_registrations_total: Counter,

/// Number of tokens registered for heartbeat notifications.
pub heartbeat_token_count: Gauge<i64, AtomicI64>,
pub heartbeat_tokens: Gauge<i64, AtomicI64>,
}

impl Metrics {
Expand Down Expand Up @@ -57,19 +57,19 @@ impl Metrics {
heartbeat_registrations_total.clone(),
);

let heartbeat_token_count = Gauge::<i64, AtomicI64>::default();
let heartbeat_tokens = Gauge::<i64, AtomicI64>::default();
registry.register(
"heartbeat_token_count",
"heartbeat_tokens",
"Number of tokens registered for heartbeat notifications",
heartbeat_token_count.clone(),
heartbeat_tokens.clone(),
);

Self {
registry,
direct_notifications_total,
heartbeat_notifications_total,
heartbeat_registrations_total,
heartbeat_token_count,
heartbeat_tokens,
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 2bcedc6

Please sign in to comment.