From 932be47cf44d2223a69b1e08b1e03efa2cfb8ceb Mon Sep 17 00:00:00 2001 From: qima Date: Mon, 20 Jan 2025 03:54:54 +0800 Subject: [PATCH] fix(metric): not to refresh entire cpu un-necessarily and too often --- ant-logging/src/metrics.rs | 2 +- ant-networking/src/metrics/mod.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ant-logging/src/metrics.rs b/ant-logging/src/metrics.rs index b6cbd29526..ded5649bbb 100644 --- a/ant-logging/src/metrics.rs +++ b/ant-logging/src/metrics.rs @@ -11,7 +11,7 @@ use std::time::Duration; use sysinfo::{self, Networks, Pid, System}; use tracing::{debug, error}; -const UPDATE_INTERVAL: Duration = Duration::from_secs(15); +const UPDATE_INTERVAL: Duration = Duration::from_secs(60); const TO_MB: u64 = 1_000_000; // The following Metrics are collected and logged diff --git a/ant-networking/src/metrics/mod.rs b/ant-networking/src/metrics/mod.rs index 32e0f0dca9..1efc7a2334 100644 --- a/ant-networking/src/metrics/mod.rs +++ b/ant-networking/src/metrics/mod.rs @@ -28,7 +28,7 @@ use prometheus_client::{ use sysinfo::{Pid, ProcessRefreshKind, System}; use tokio::time::Duration; -const UPDATE_INTERVAL: Duration = Duration::from_secs(15); +const UPDATE_INTERVAL: Duration = Duration::from_secs(60); const TO_MB: u64 = 1_000_000; /// The shared recorders that are used to record metrics. @@ -251,7 +251,6 @@ impl NetworkMetricsRecorder { tokio::spawn(async move { loop { - system.refresh_cpu(); system.refresh_process_specifics(pid, process_refresh_kind); if let (Some(process), Some(core_count)) = (system.process(pid), physical_core_count)