mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 13:27:43 +00:00
feat: adjust metrics push interval to 3 seconds (#686)
- Reduce metrics push frequency from default to 3s for better performance - Optimize resource utilization during metrics collection - Improve real-time monitoring responsiveness Related to admin metrics optimization on fix/admin-metrics branch
This commit is contained in:
@@ -23,7 +23,7 @@ use rustfs_common::{
|
||||
use rustfs_madmin::metrics::{DiskIOStats, DiskMetric, RealtimeMetrics};
|
||||
use rustfs_utils::os::get_drive_stats;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::info;
|
||||
use tracing::{debug, info};
|
||||
|
||||
use crate::{
|
||||
admin_server_info::get_local_server_property,
|
||||
@@ -44,7 +44,7 @@ pub struct CollectMetricsOpts {
|
||||
pub struct MetricType(u32);
|
||||
|
||||
impl MetricType {
|
||||
// 定义一些常量
|
||||
// Define some constants
|
||||
pub const NONE: MetricType = MetricType(0);
|
||||
pub const SCANNER: MetricType = MetricType(1 << 0);
|
||||
pub const DISK: MetricType = MetricType(1 << 1);
|
||||
@@ -70,8 +70,18 @@ impl MetricType {
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect local metrics based on the specified types and options.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `types` - A `MetricType` specifying which types of metrics to collect.
|
||||
/// * `opts` - A reference to `CollectMetricsOpts` containing additional options for metric collection.
|
||||
///
|
||||
/// # Returns
|
||||
/// * A `RealtimeMetrics` struct containing the collected metrics.
|
||||
///
|
||||
pub async fn collect_local_metrics(types: MetricType, opts: &CollectMetricsOpts) -> RealtimeMetrics {
|
||||
info!("collect_local_metrics");
|
||||
debug!("collect_local_metrics");
|
||||
let mut real_time_metrics = RealtimeMetrics::default();
|
||||
if types.0 == MetricType::NONE.0 {
|
||||
info!("types is None, return");
|
||||
@@ -93,13 +103,13 @@ pub async fn collect_local_metrics(types: MetricType, opts: &CollectMetricsOpts)
|
||||
}
|
||||
|
||||
if types.contains(&MetricType::DISK) {
|
||||
info!("start get disk metrics");
|
||||
debug!("start get disk metrics");
|
||||
let mut aggr = DiskMetric {
|
||||
collected_at: Utc::now(),
|
||||
..Default::default()
|
||||
};
|
||||
for (name, disk) in collect_local_disks_metrics(&opts.disks).await.into_iter() {
|
||||
info!("got disk metric, name: {name}, metric: {disk:?}");
|
||||
debug!("got disk metric, name: {name}, metric: {disk:?}");
|
||||
real_time_metrics.by_disk.insert(name, disk.clone());
|
||||
aggr.merge(&disk);
|
||||
}
|
||||
@@ -107,7 +117,7 @@ pub async fn collect_local_metrics(types: MetricType, opts: &CollectMetricsOpts)
|
||||
}
|
||||
|
||||
if types.contains(&MetricType::SCANNER) {
|
||||
info!("start get scanner metrics");
|
||||
debug!("start get scanner metrics");
|
||||
let metrics = globalMetrics.report().await;
|
||||
real_time_metrics.aggregated.scanner = Some(metrics);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user