Update version to 0.1.21 and fix dashboard data caching
All checks were successful
Build and Release / build-and-release (push) Successful in 1m13s

- Separate dashboard updates from email notifications for immediate status aggregation
- Add metric caching to MetricCollectionManager for instant dashboard updates
- Dashboard now receives cached data every 1 second instead of waiting for collection intervals
- Fix transmission to use cached metrics rather than triggering fresh collection
- Email notifications maintain separate 60-second batching interval
- Update configurable email notification aggregation interval
This commit is contained in:
2025-10-28 12:16:31 +01:00
parent a2519b2814
commit 43242debce
8 changed files with 41 additions and 15 deletions

View File

@@ -21,6 +21,7 @@ struct TimedCollector {
pub struct MetricCollectionManager {
collectors: Vec<TimedCollector>,
status_tracker: StatusTracker,
cached_metrics: Vec<Metric>,
}
impl MetricCollectionManager {
@@ -177,6 +178,7 @@ impl MetricCollectionManager {
Ok(Self {
collectors,
status_tracker: StatusTracker::new(),
cached_metrics: Vec::new(),
})
}
@@ -198,6 +200,9 @@ impl MetricCollectionManager {
}
}
}
// Cache the collected metrics
self.cached_metrics = all_metrics.clone();
Ok(all_metrics)
}
@@ -231,6 +236,18 @@ impl MetricCollectionManager {
}
}
}
// Update cache with newly collected metrics
if !all_metrics.is_empty() {
// Merge new metrics with cached metrics (replace by name)
for new_metric in &all_metrics {
// Remove any existing metric with the same name
self.cached_metrics.retain(|cached| cached.name != new_metric.name);
// Add the new metric
self.cached_metrics.push(new_metric.clone());
}
}
Ok(all_metrics)
}
@@ -238,5 +255,10 @@ impl MetricCollectionManager {
pub async fn collect_all_metrics(&mut self) -> Result<Vec<Metric>> {
self.collect_metrics_timed().await
}
/// Get cached metrics without triggering fresh collection
pub fn get_cached_metrics(&self) -> Vec<Metric> {
self.cached_metrics.clone()
}
}