Skip to content

Commit

Permalink
do not store time metrics every second
Browse files Browse the repository at this point in the history
instead, aggregate them at the minute level
  • Loading branch information
Geal authored and FlorentinDUBOIS committed Jul 13, 2022
1 parent e82588a commit aa1176a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/src/metrics/local_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,19 +784,18 @@ impl LocalDrain {

fn store_time_metric(&mut self, key: &str, cluster_id: &str, backend_id: Option<&str>, t: usize) -> Result<(), sled::Error> {
let now = OffsetDateTime::now_utc();
let timestamp = now.unix_timestamp();
let _res = self.store_time_metric_at(key, cluster_id, backend_id, timestamp, t)?;
//let timestamp = now.unix_timestamp();
//let _res = self.store_time_metric_at(key, cluster_id, backend_id, timestamp, t)?;

let second = now.second();
// we also aggregate at second zero
if second != 0 {
//if second != 0 {
let previous_minute = now - time::Duration::seconds(second as i64);
let timestamp = previous_minute.unix_timestamp();
info!("WILL REWRITE TIME METRIC AT {}", timestamp);
let _res = self.store_time_metric_at(key, cluster_id, backend_id, timestamp, t)?;
} else {
//FIXME: here we should delete all the measurements for the previous 60 seconds
}
//} else {
//}

Ok(())
}
Expand Down

0 comments on commit aa1176a

Please sign in to comment.