refactor(metrics): unify process sampling and split network IO (#2590)

This commit is contained in:
houseme
2026-04-18 23:30:44 +08:00
committed by GitHub
parent f9b5ad17a9
commit 116db4f5d9
12 changed files with 491 additions and 250 deletions
@@ -355,10 +355,10 @@ pub enum MetricName {
ProcessCPUUtilization,
/// Process disk I/O bytes
ProcessDiskIO,
/// Process network I/O bytes
ProcessNetworkIO,
/// Process network I/O bytes per interface
ProcessNetworkIOPerInterface,
/// Host network I/O bytes
HostNetworkIO,
/// Host network I/O bytes per interface
HostNetworkIOPerInterface,
/// Process status (0: Running, 1: Sleeping, 2: Zombie, 3: Other)
ProcessStatus,
/// Process GPU memory usage in bytes
@@ -688,8 +688,8 @@ impl MetricName {
Self::ProcessCPUUsage => "cpu_usage".to_string(),
Self::ProcessCPUUtilization => "cpu_utilization".to_string(),
Self::ProcessDiskIO => "disk_io".to_string(),
Self::ProcessNetworkIO => "network_io".to_string(),
Self::ProcessNetworkIOPerInterface => "network_io_per_interface".to_string(),
Self::HostNetworkIO => "network_io".to_string(),
Self::HostNetworkIOPerInterface => "network_io_per_interface".to_string(),
Self::ProcessGpuMemoryUsage => "gpu_memory_usage".to_string(),
Self::ProcessStatus => "status".to_string(),
@@ -27,6 +27,7 @@ pub enum MetricSubsystem {
// system related subsystems
SystemNetworkInternode,
SystemNetworkHost,
SystemDrive,
SystemMemory,
SystemCpu,
@@ -68,6 +69,7 @@ impl MetricSubsystem {
// system related subsystems
Self::SystemNetworkInternode => "/system/network/internode",
Self::SystemNetworkHost => "/system/network/host",
Self::SystemDrive => "/system/drive",
Self::SystemMemory => "/system/memory",
Self::SystemCpu => "/system/cpu",
@@ -115,6 +117,7 @@ impl MetricSubsystem {
// System-related subsystems
"/system/network/internode" => Self::SystemNetworkInternode,
"/system/network/host" => Self::SystemNetworkHost,
"/system/drive" => Self::SystemDrive,
"/system/memory" => Self::SystemMemory,
"/system/cpu" => Self::SystemCpu,
@@ -183,6 +186,7 @@ pub mod subsystems {
pub const BUCKET_REPLICATION: MetricSubsystem = MetricSubsystem::BucketReplication;
pub const SYSTEM_GPU: MetricSubsystem = MetricSubsystem::SystemGpu;
pub const SYSTEM_NETWORK_INTERNODE: MetricSubsystem = MetricSubsystem::SystemNetworkInternode;
pub const SYSTEM_NETWORK_HOST: MetricSubsystem = MetricSubsystem::SystemNetworkHost;
pub const SYSTEM_DRIVE: MetricSubsystem = MetricSubsystem::SystemDrive;
pub const SYSTEM_MEMORY: MetricSubsystem = MetricSubsystem::SystemMemory;
pub const SYSTEM_CPU: MetricSubsystem = MetricSubsystem::SystemCpu;
@@ -210,6 +214,7 @@ mod tests {
fn test_metric_subsystem_formatting() {
assert_eq!(MetricSubsystem::ApiRequests.as_str(), "api_requests");
assert_eq!(MetricSubsystem::SystemNetworkInternode.as_str(), "system_network_internode");
assert_eq!(MetricSubsystem::SystemNetworkHost.as_str(), "system_network_host");
assert_eq!(MetricSubsystem::BucketApi.as_str(), "bucket_api");
assert_eq!(MetricSubsystem::ClusterHealth.as_str(), "cluster_health");