Skip to main content

Mountain/IPC/Enhanced/PerformanceDashboard/
DashboardHelpers.rs

1#![allow(unused_variables, dead_code, unused_imports)]
2
3//! Pure utility functions shared across `Dashboard` methods.
4//!
5//! All functions are deterministic and side-effect-free, making them
6//! straightforward to unit-test and reuse outside the dashboard impl.
7
8use super::MetricType::Enum as MetricType;
9
10/// Current process memory usage in MB (stub: returns 100.0 until real
11/// platform metrics are wired).
12pub fn get_memory_usage() -> Result<f64, String> { Ok(100.0) }
13
14/// Current process CPU usage percentage (stub: returns 25.0 until real
15/// platform metrics are wired).
16pub fn get_cpu_usage() -> Result<f64, String> { Ok(25.0) }
17
18/// Generate a new UUID v4 string for use as a trace identifier.
19pub fn generate_trace_id() -> String { uuid::Uuid::new_v4().to_string() }
20
21/// Generate a new UUID v4 string for use as a span identifier.
22pub fn generate_span_id() -> String { uuid::Uuid::new_v4().to_string() }
23
24/// Generate a new UUID v4 string for use as an alert identifier.
25pub fn generate_alert_id() -> String { uuid::Uuid::new_v4().to_string() }
26
27/// Human-readable display name for a `MetricType` variant.
28pub fn metric_type_name(metric_type:&MetricType) -> &'static str {
29	match metric_type {
30		MetricType::MessageProcessingTime => "Message Processing Time",
31
32		MetricType::ConnectionLatency => "Connection Latency",
33
34		MetricType::MemoryUsage => "Memory Usage",
35
36		MetricType::CpuUsage => "CPU Usage",
37
38		MetricType::NetworkThroughput => "Network Throughput",
39
40		MetricType::ErrorRate => "Error Rate",
41
42		MetricType::QueueSize => "Queue Size",
43	}
44}