pub struct PerformanceDashboard {
config: DashboardConfig,
metrics: Arc<RwLock<VecDeque<PerformanceMetric>>>,
traces: Arc<RwLock<HashMap<String, TraceSpan>>>,
alerts: Arc<RwLock<VecDeque<PerformanceAlert>>>,
statistics: Arc<RwLock<DashboardStatistics>>,
is_running: Arc<Mutex<bool>>,
}Expand description
Performance dashboard
Fields§
§config: DashboardConfig§metrics: Arc<RwLock<VecDeque<PerformanceMetric>>>§traces: Arc<RwLock<HashMap<String, TraceSpan>>>§alerts: Arc<RwLock<VecDeque<PerformanceAlert>>>§statistics: Arc<RwLock<DashboardStatistics>>§is_running: Arc<Mutex<bool>>Implementations§
Source§impl PerformanceDashboard
impl PerformanceDashboard
Sourcepub fn new(config: DashboardConfig) -> Self
pub fn new(config: DashboardConfig) -> Self
Create a new performance dashboard
Sourcepub async fn record_metric(&self, metric: PerformanceMetric)
pub async fn record_metric(&self, metric: PerformanceMetric)
Record a performance metric
Sourcepub async fn start_trace_span(&self, operation_name: String) -> TraceSpan
pub async fn start_trace_span(&self, operation_name: String) -> TraceSpan
Start a new trace span
Sourcepub async fn add_trace_log(
&self,
span_id: &str,
log: TraceLog,
) -> Result<(), String>
pub async fn add_trace_log( &self, span_id: &str, log: TraceLog, ) -> Result<(), String>
Add log to trace span
Sourceasync fn start_metrics_collection(&self)
async fn start_metrics_collection(&self)
Start metrics collection
Sourceasync fn start_alert_monitoring(&self)
async fn start_alert_monitoring(&self)
Start alert monitoring
Sourceasync fn start_data_cleanup(&self)
async fn start_data_cleanup(&self)
Start data cleanup
Sourceasync fn collect_system_metrics(&self)
async fn collect_system_metrics(&self)
Collect system metrics
Sourceasync fn update_statistics(&self)
async fn update_statistics(&self)
Update dashboard statistics
Sourceasync fn check_alerts(&self, metric: &PerformanceMetric)
async fn check_alerts(&self, metric: &PerformanceMetric)
Check for performance alerts
Sourceasync fn check_performance_alerts(&self)
async fn check_performance_alerts(&self)
Check performance alerts periodically
Sourceasync fn cleanup_old_data(&self)
async fn cleanup_old_data(&self)
Cleanup old data
Sourcefn get_memory_usage() -> Result<f64, String>
fn get_memory_usage() -> Result<f64, String>
Get memory usage (simplified implementation)
Sourcefn get_cpu_usage() -> Result<f64, String>
fn get_cpu_usage() -> Result<f64, String>
Get CPU usage (simplified implementation)
Sourcefn generate_trace_id() -> String
fn generate_trace_id() -> String
Generate trace ID
Sourcefn generate_span_id() -> String
fn generate_span_id() -> String
Generate span ID
Sourcefn generate_alert_id() -> String
fn generate_alert_id() -> String
Generate alert ID
Sourcefn metric_type_name(metric_type: &MetricType) -> &'static str
fn metric_type_name(metric_type: &MetricType) -> &'static str
Get metric type name
Sourcepub async fn get_statistics(&self) -> DashboardStatistics
pub async fn get_statistics(&self) -> DashboardStatistics
Get dashboard statistics
Sourcepub async fn get_recent_metrics(&self, limit: usize) -> Vec<PerformanceMetric>
pub async fn get_recent_metrics(&self, limit: usize) -> Vec<PerformanceMetric>
Get recent metrics
Sourcepub async fn get_active_alerts(&self) -> Vec<PerformanceAlert>
pub async fn get_active_alerts(&self) -> Vec<PerformanceAlert>
Get active alerts
Sourcepub fn default_dashboard() -> Self
pub fn default_dashboard() -> Self
Create a performance dashboard with default configuration
Sourcepub fn high_frequency_dashboard() -> Self
pub fn high_frequency_dashboard() -> Self
Create a high-frequency dashboard
Source§impl PerformanceDashboard
Utility functions for performance monitoring
impl PerformanceDashboard
Utility functions for performance monitoring
Sourcepub fn create_metric(
metric_type: MetricType,
value: f64,
channel: Option<String>,
tags: HashMap<String, String>,
) -> PerformanceMetric
pub fn create_metric( metric_type: MetricType, value: f64, channel: Option<String>, tags: HashMap<String, String>, ) -> PerformanceMetric
Create a performance metric
Sourcepub fn create_trace_log(
message: String,
level: LogLevel,
fields: HashMap<String, String>,
) -> TraceLog
pub fn create_trace_log( message: String, level: LogLevel, fields: HashMap<String, String>, ) -> TraceLog
Create a trace log
Sourcepub fn calculate_performance_score(
average_processing_time: f64,
error_rate: f64,
throughput: f64,
) -> f64
pub fn calculate_performance_score( average_processing_time: f64, error_rate: f64, throughput: f64, ) -> f64
Calculate performance score
Sourcepub fn format_metric_value(metric_type: &MetricType, value: f64) -> String
pub fn format_metric_value(metric_type: &MetricType, value: f64) -> String
Format metric value for display
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PerformanceDashboard
impl !RefUnwindSafe for PerformanceDashboard
impl Send for PerformanceDashboard
impl Sync for PerformanceDashboard
impl Unpin for PerformanceDashboard
impl !UnwindSafe for PerformanceDashboard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].