diff --git a/Cargo.lock b/Cargo.lock index 55a1d67..22360fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1653,6 +1653,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "uom", ] [[package]] diff --git a/crates/ptth_file_server_bin/Cargo.toml b/crates/ptth_file_server_bin/Cargo.toml index af3cf68..8d91c39 100644 --- a/crates/ptth_file_server_bin/Cargo.toml +++ b/crates/ptth_file_server_bin/Cargo.toml @@ -18,6 +18,7 @@ structopt = "0.3.20" tokio = { version = "0.2.22", features = ["full"] } tracing = "0.1.21" tracing-subscriber = "0.2.15" +uom = "0.30.0" ptth_core = { path = "../ptth_core" } ptth_server = { path = "../ptth_server" } diff --git a/crates/ptth_file_server_bin/src/main.rs b/crates/ptth_file_server_bin/src/main.rs index 9ae3f47..b92d6e9 100644 --- a/crates/ptth_file_server_bin/src/main.rs +++ b/crates/ptth_file_server_bin/src/main.rs @@ -97,24 +97,46 @@ async fn main () -> Result <(), anyhow::Error> { config_file.name.unwrap_or_else (|| "PTTH File Server".to_string ()) ); - let metrics_gauges = Arc::new (ArcSwap::default ()); + let metrics_interval = Arc::new (ArcSwap::default ()); - let gauge_writer = Arc::clone (&metrics_gauges); + let interval_writer = Arc::clone (&metrics_interval); tokio::spawn (async move { - let mut interval = tokio::time::interval (std::time::Duration::from_secs (2)); + use std::time::Duration; + + use uom::si::ratio::percent; + + let mut interval = tokio::time::interval (Duration::from_secs (60)); + + let mut counter = 0_u64; + let mut next_10_time = counter; + let mut metrics_at_last_10: Arc