refactor: update metrics out of phase

Emit the metrics out-of-phase with the metric scraper.
pull/24376/head
Dom Dwyer 2023-07-06 15:36:30 +02:00
parent d979739576
commit d46a5f0c51
No known key found for this signature in database
GPG Key ID: E4C40DBD9157879A
1 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,12 @@ use std::{borrow::Cow, path::PathBuf, time::Duration};
use metric::{Attributes, U64Gauge};
use sysinfo::{DiskExt, RefreshKind, System, SystemExt};
/// The interval at which disk metrics are updated.
///
/// This is purposely chosen to be out-of-phase w.r.t the default metric scrape
/// interval.
const UPDATE_INTERVAL: Duration = Duration::from_secs(13);
/// A periodic reporter of disk capacity / free statistics for a given
/// directory.
#[derive(Debug)]
@ -68,7 +74,7 @@ impl DiskSpaceMetrics {
/// Start the [`DiskSpaceMetrics`] evaluation loop, blocking forever.
pub async fn run(mut self) {
let mut interval = tokio::time::interval(Duration::from_secs(10));
let mut interval = tokio::time::interval(UPDATE_INTERVAL);
loop {
interval.tick().await;