1pub use crate::logging::metrics::*;
8
9#[cfg(feature = "prometheus")]
10pub mod prometheus;
11
12#[cfg(feature = "prometheus")]
13pub mod http_server;
14
15#[cfg(feature = "prometheus")]
16pub use self::prometheus::PrometheusExporter;
17
18#[cfg(feature = "prometheus")]
19pub use self::http_server::MetricsServer;
20
21#[derive(Debug, Clone)]
23pub struct MetricsConfig {
24 pub enabled: bool,
26 pub port: u16,
28 pub bind_address: std::net::IpAddr,
30 pub update_interval: std::time::Duration,
32}
33
34impl Default for MetricsConfig {
35 fn default() -> Self {
36 Self {
37 enabled: false,
38 port: 9090,
39 bind_address: std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)),
40 update_interval: std::time::Duration::from_secs(30),
41 }
42 }
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_metrics_config_default() {
51 let config = MetricsConfig::default();
52 assert!(!config.enabled);
53 assert_eq!(config.port, 9090);
54 assert_eq!(config.bind_address, std::net::IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0)));
55 assert_eq!(config.update_interval, std::time::Duration::from_secs(30));
56 }
57}