pub struct MonitoringConfig {
pub enabled: bool,
pub sample_rate: usize,
pub alert_threshold: f64,
pub max_variation_percent: f64,
pub timeout: Duration,
}Expand description
Configuration for runtime cryptographic operation monitoring.
This struct controls how the monitoring system behaves, including sampling rates, alert thresholds, and performance constraints. Proper configuration balances security monitoring with production performance requirements.
§Security vs Performance Trade-offs
- Higher sample rates: Better anomaly detection but increased overhead
- Lower thresholds: More sensitive detection but higher false positives
- Shorter timeouts: Faster failure detection but may flag legitimate operations
§Recommended Settings
- Development: High sample rate (1-10), low thresholds for testing
- Production: Low sample rate (100-1000), balanced thresholds for monitoring
- High-security: Medium sample rate (10-100), strict thresholds
§Fields
enabled: Master switch for all monitoring functionalitysample_rate: How often to monitor operations (1 = always, higher = less frequent)alert_threshold: Statistical threshold for anomaly detection (in standard deviations)max_variation_percent: Maximum allowed timing variation as percentagetimeout: Maximum allowed duration before timing out an operation
Fields§
§enabled: boolMaster enable switch for monitoring functionality
sample_rate: usizeSample rate for monitoring (1 = monitor every operation, higher values = less frequent) Lower values provide better coverage but increase performance overhead
alert_threshold: f64Statistical threshold for anomaly detection in standard deviations Values like 2.0-3.0 are typical for detecting significant deviations
max_variation_percent: f64Maximum allowed timing variation as a percentage of mean execution time Helps detect systems under load or environmental changes
timeout: DurationMaximum allowed duration for any monitored operation Operations exceeding this timeout trigger immediate alerts
Trait Implementations§
Source§impl Clone for MonitoringConfig
impl Clone for MonitoringConfig
Source§fn clone(&self) -> MonitoringConfig
fn clone(&self) -> MonitoringConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MonitoringConfig
impl Debug for MonitoringConfig
Source§impl Default for MonitoringConfig
impl Default for MonitoringConfig
Source§fn default() -> Self
fn default() -> Self
Creates a default monitoring configuration optimized for production use.
The default configuration prioritizes performance while providing basic monitoring capabilities. Monitoring is disabled by default to avoid performance impact in production environments.
§Default Values
enabled: false- Monitoring disabled for performancesample_rate: 1000- Monitor 1 in 1000 operationsalert_threshold: 3.0- Alert on 3-sigma deviations (99.7% confidence)max_variation_percent: 10.0- Allow 10% timing variationtimeout: 100ms- Operations should complete within 100 milliseconds
§Usage
use clock_curve_math::ct::monitoring::MonitoringConfig;
// Use defaults (monitoring disabled)
let config = MonitoringConfig::default();
// Enable monitoring for development
let dev_config = MonitoringConfig {
enabled: true,
sample_rate: 10, // Monitor more frequently
..MonitoringConfig::default()
};