diff --git a/crates/ptth_server/src/file_server/metrics.rs b/crates/ptth_server/src/file_server/metrics.rs index 37f6c00..5535104 100644 --- a/crates/ptth_server/src/file_server/metrics.rs +++ b/crates/ptth_server/src/file_server/metrics.rs @@ -1,4 +1,7 @@ -use std::sync::Arc; +use std::{ + sync::Arc, + time::{Duration, Instant}, +}; use arc_swap::ArcSwap; use chrono::{DateTime, Utc}; @@ -35,6 +38,8 @@ pub struct Startup { #[derive (Debug, serde::Serialize)] pub struct Interval { + #[serde (skip)] + pub at: Instant, pub utc: DateTime , pub rss_mib: u64, @@ -94,6 +99,7 @@ impl Interval { let rss_mib = mem.rss ().get:: (); let x = Self { + at: Instant::now (), utc: Utc::now (), rss_mib, cpu_usage, @@ -104,15 +110,53 @@ impl Interval { pub async fn monitor (interval_writer: Arc >>) { - use std::time::Duration; - use uom::si::ratio::percent; let mut interval = tokio::time::interval (Duration::from_secs (60)); + #[derive (Default)] + struct Window { + window_length: u64, + next_interval: u64, + last_metrics: Arc