From 5eaa6c1745c5c3b766839370e2592c73ab3e7b7f Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 22 Aug 2026 00:04:12 +0800 Subject: [PATCH] chore(obs): ReplicationStats -> ReplicationMetricsSnapshot, BucketReplicationStats -> BucketReplicationMetricsSnapshot Rename in-obs-crate ReplicationStats and BucketReplicationStats to ReplicationMetricsSnapshot and BucketReplicationMetricsSnapshot respectively. No serde impact (these types are Prometheus metric collectors, not serialized). No external consumers found outside the obs crate. --- .../src/metrics/collectors/bucket_replication.rs | 10 +++++----- crates/obs/src/metrics/collectors/mod.rs | 4 ++-- crates/obs/src/metrics/collectors/replication.rs | 12 ++++++------ crates/obs/src/metrics/scheduler.rs | 4 ++-- crates/obs/src/metrics/stats_collector.rs | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/crates/obs/src/metrics/collectors/bucket_replication.rs b/crates/obs/src/metrics/collectors/bucket_replication.rs index a393c8e38..bbe7de6fe 100644 --- a/crates/obs/src/metrics/collectors/bucket_replication.rs +++ b/crates/obs/src/metrics/collectors/bucket_replication.rs @@ -75,7 +75,7 @@ pub struct BucketReplicationBandwidthStats { } #[derive(Debug, Clone, Default)] -pub struct BucketReplicationStats { +pub struct BucketReplicationMetricsSnapshot { pub bucket: String, pub total_failed_bytes: u64, pub total_failed_count: u64, @@ -107,7 +107,7 @@ pub struct BucketReplicationStats { #[derive(Debug, Clone, Default)] pub(crate) struct BucketReplicationRuntimeStats { - pub(crate) stats: BucketReplicationStats, + pub(crate) stats: BucketReplicationMetricsSnapshot, pub(crate) target_flows: Vec, } @@ -182,7 +182,7 @@ fn push_proxy_request_result_metrics( } } -pub fn collect_bucket_replication_metrics(stats: &[BucketReplicationStats]) -> Vec { +pub fn collect_bucket_replication_metrics(stats: &[BucketReplicationMetricsSnapshot]) -> Vec { if stats.is_empty() { return Vec::new(); } @@ -572,7 +572,7 @@ mod tests { #[test] fn test_collect_bucket_replication_metrics() { let stats = vec![BucketReplicationRuntimeStats { - stats: BucketReplicationStats { + stats: BucketReplicationMetricsSnapshot { bucket: "b1".to_string(), total_failed_bytes: 64, total_failed_count: 2, @@ -876,7 +876,7 @@ mod tests { #[test] fn test_collect_bucket_replication_metrics_empty() { - let stats: Vec = Vec::new(); + let stats: Vec = Vec::new(); let metrics = collect_bucket_replication_metrics(&stats); assert!(metrics.is_empty()); } diff --git a/crates/obs/src/metrics/collectors/mod.rs b/crates/obs/src/metrics/collectors/mod.rs index 67df19035..9b8e57e18 100644 --- a/crates/obs/src/metrics/collectors/mod.rs +++ b/crates/obs/src/metrics/collectors/mod.rs @@ -48,7 +48,7 @@ pub(crate) use bucket_replication::{ BucketReplicationTargetFlowStats, collect_bucket_replication_backlog_metrics, collect_bucket_replication_runtime_metrics, }; pub use bucket_replication::{ - BucketReplicationBandwidthStats, BucketReplicationStats, BucketReplicationTargetStats, + BucketReplicationBandwidthStats, BucketReplicationMetricsSnapshot, BucketReplicationTargetStats, collect_bucket_replication_bandwidth_metrics, collect_bucket_replication_metrics, }; pub use cluster::{ClusterStats, collect_cluster_metrics}; @@ -69,7 +69,7 @@ pub use notification::{NotificationStats, collect_notification_metrics}; pub(crate) use notification_target::{NotificationTargetRuntimeStats, collect_notification_target_runtime_metrics}; pub use notification_target::{NotificationTargetStats, collect_notification_target_metrics}; pub(crate) use replication::{ReplicationRuntimeStats, collect_replication_runtime_metrics}; -pub use replication::{ReplicationStats, collect_replication_metrics}; +pub use replication::{ReplicationMetricsSnapshot, collect_replication_metrics}; pub(crate) use request::{ApiRequestMetricSupport, ApiRequestStats, collect_request_metrics}; pub use resource::{ResourceStats, collect_resource_metrics}; pub(crate) use scanner::{ScannerRuntimeStats, collect_scanner_runtime_metrics}; diff --git a/crates/obs/src/metrics/collectors/replication.rs b/crates/obs/src/metrics/collectors/replication.rs index 4dc347058..d483c71ef 100644 --- a/crates/obs/src/metrics/collectors/replication.rs +++ b/crates/obs/src/metrics/collectors/replication.rs @@ -22,7 +22,7 @@ use crate::metrics::schema::replication::*; /// Replication statistics. #[derive(Debug, Clone, Default)] -pub struct ReplicationStats { +pub struct ReplicationMetricsSnapshot { /// Average number of active replication workers pub average_active_workers: f64, /// Average queued bytes since server start @@ -54,13 +54,13 @@ pub struct ReplicationStats { #[derive(Debug, Clone, Default)] pub(crate) struct ReplicationRuntimeStats { pub(crate) server: String, - pub(crate) stats: ReplicationStats, + pub(crate) stats: ReplicationMetricsSnapshot, } /// Collects replication metrics from the given stats. /// /// Returns a vector of Prometheus metrics for replication statistics. -pub fn collect_replication_metrics(stats: &ReplicationStats) -> Vec { +pub fn collect_replication_metrics(stats: &ReplicationMetricsSnapshot) -> Vec { vec![ PrometheusMetric::from_descriptor(&REPLICATION_AVERAGE_ACTIVE_WORKERS_MD, stats.average_active_workers), PrometheusMetric::from_descriptor(&REPLICATION_AVERAGE_QUEUED_BYTES_MD, stats.average_queued_bytes as f64), @@ -120,7 +120,7 @@ mod tests { #[test] fn test_collect_replication_metrics() { - let stats = ReplicationStats { + let stats = ReplicationMetricsSnapshot { average_active_workers: 8.5, average_queued_bytes: 1024 * 1024 * 40, average_queued_count: 240, @@ -182,7 +182,7 @@ mod tests { #[test] fn test_collect_replication_metrics_default() { - let stats = ReplicationStats::default(); + let stats = ReplicationMetricsSnapshot::default(); let metrics = collect_replication_metrics(&stats); assert_eq!(metrics.len(), 13); @@ -194,7 +194,7 @@ mod tests { #[test] fn replication_stats_struct_literal_keeps_legacy_fields() { - let stats = ReplicationStats { + let stats = ReplicationMetricsSnapshot { average_active_workers: 1.0, average_queued_bytes: 2, average_queued_count: 3, diff --git a/crates/obs/src/metrics/scheduler.rs b/crates/obs/src/metrics/scheduler.rs index 088799d5e..29734268f 100644 --- a/crates/obs/src/metrics/scheduler.rs +++ b/crates/obs/src/metrics/scheduler.rs @@ -2811,14 +2811,14 @@ mod tests { #[test] fn replication_proxy_bucket_keys_detect_removed_buckets() { let previous = repl_proxy_bucket_live_keys(&[BucketReplicationRuntimeStats { - stats: crate::metrics::BucketReplicationStats { + stats: crate::metrics::BucketReplicationMetricsSnapshot { bucket: "photos".to_string(), ..Default::default() }, ..Default::default() }]); let current = repl_proxy_bucket_live_keys(&[BucketReplicationRuntimeStats { - stats: crate::metrics::BucketReplicationStats { + stats: crate::metrics::BucketReplicationMetricsSnapshot { bucket: "logs".to_string(), ..Default::default() }, diff --git a/crates/obs/src/metrics/stats_collector.rs b/crates/obs/src/metrics/stats_collector.rs index 20e461952..82d0f6297 100644 --- a/crates/obs/src/metrics/stats_collector.rs +++ b/crates/obs/src/metrics/stats_collector.rs @@ -21,12 +21,12 @@ use crate::metrics::collectors::scanner::{ScannerActiveBucketDriveStats, ScannerBucketDriveResultStats, ScannerSourceWorkStats}; use crate::metrics::collectors::{ ApiRequestMetricSupport, ApiRequestStats, BucketReplicationBacklogStats, BucketReplicationBandwidthStats, - BucketReplicationRuntimeStats, BucketReplicationStats, BucketReplicationTargetBacklogStats, BucketReplicationTargetFlowStats, + BucketReplicationRuntimeStats, BucketReplicationMetricsSnapshot, BucketReplicationTargetBacklogStats, BucketReplicationTargetFlowStats, BucketReplicationTargetStats, BucketStats, BucketUsageStats, ClusterConfigStats, ClusterHealthStats, ClusterStats, ClusterUsageStats, CompressionClusterStats, CpuStats, DiskStats, DriveCountStats, DriveDetailedStats, DriveRuntimeDetailedStats, ErasureSetStats, HostNetworkStats, IamStats, IlmActionTaskStats, IlmBackpressureStats, IlmQueueTaskStats, IlmRuntimeStats, IlmStats, IlmTaskEventStats, MemoryStats, NetworkStats, ProcessStats, ProcessStatusType, - ReplicationStats, ResourceStats, ScannerRuntimeStats, ScannerStats, + ReplicationMetricsSnapshot, ResourceStats, ScannerRuntimeStats, ScannerStats, }; use crate::metrics::runtime_sources::{ObsIlmRuntimeSnapshot, bucket_monitor_handle, iam_metrics_snapshot, ilm_runtime_snapshot}; use crate::metrics::{ @@ -266,7 +266,7 @@ fn bucket_replication_detail_from_snapshot(stats: ObsBucketReplicationStatsSnaps BucketReplicationRuntimeStats { target_flows, - stats: BucketReplicationStats { + stats: BucketReplicationMetricsSnapshot { bucket, total_failed_bytes: stats.total_failed_bytes, total_failed_count: stats.total_failed_count, @@ -298,7 +298,7 @@ fn bucket_replication_detail_from_snapshot(stats: ObsBucketReplicationStatsSnaps } } -async fn obs_site_replication_stats() -> ReplicationStats { +async fn obs_site_replication_stats() -> ReplicationMetricsSnapshot { let current_data_transfer_rate = obs_bucket_replication_bandwidth_stats() .into_iter() .flatten() @@ -306,7 +306,7 @@ async fn obs_site_replication_stats() -> ReplicationStats { .sum::(); let stats = obs_replication_site_stats_snapshot(current_data_transfer_rate).await; - ReplicationStats { + ReplicationMetricsSnapshot { average_active_workers: stats.average_active_workers, average_queued_bytes: stats.average_queued_bytes, average_queued_count: stats.average_queued_count, @@ -648,7 +648,7 @@ pub fn collect_bucket_replication_bandwidth_stats() -> Vec Vec { +pub async fn collect_bucket_replication_detail_stats() -> Vec { obs_bucket_replication_stats_snapshot() .await .into_iter() @@ -662,7 +662,7 @@ pub(crate) async fn collect_bucket_replication_stats_bundle() } /// Collect site-level replication stats from the global replication runtime. -pub async fn collect_replication_stats() -> ReplicationStats { +pub async fn collect_replication_stats() -> ReplicationMetricsSnapshot { obs_site_replication_stats().await }