use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ObservabilityConfig {
pub logging: LoggingConfig,
pub telemetry: TelemetryConfig,
pub profiling: ProfilingConfig,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LoggingConfig {
pub level: String,
pub format: LogFormat,
pub output: LogOutput,
pub file_path: Option<PathBuf>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum LogFormat {
Text,
Json,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum LogOutput {
Stdout,
File(String),
Syslog,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TelemetryConfig {
pub metrics_enabled: bool,
pub tracing_enabled: bool,
pub tracing_endpoint: Option<String>,
pub metrics_path: String,
pub health_check_path: String,
pub system_metrics_interval: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProfilingConfig {
pub cpu_profiling: bool,
pub memory_profiling: bool,
pub output_dir: PathBuf,
pub sample_rate: f64,
pub chrome_tracing: bool,
pub perf_profiling: bool,
}
impl Default for ObservabilityConfig {
fn default() -> Self {
ObservabilityConfig {
logging: LoggingConfig {
level: "info".to_string(),
format: LogFormat::Text,
output: LogOutput::Stdout,
file_path: None,
},
telemetry: TelemetryConfig {
metrics_enabled: true,
tracing_enabled: false,
tracing_endpoint: None,
metrics_path: "/metrics".to_string(),
health_check_path: "/health".to_string(),
system_metrics_interval: 5,
},
profiling: ProfilingConfig {
cpu_profiling: false,
memory_profiling: false,
output_dir: PathBuf::from("./profiles"),
sample_rate: 1.0,
chrome_tracing: false,
perf_profiling: false,
},
}
}
}
impl Default for LoggingConfig {
fn default() -> Self {
LoggingConfig {
level: "info".to_string(),
format: LogFormat::Text,
output: LogOutput::Stdout,
file_path: None,
}
}
}
impl Default for TelemetryConfig {
fn default() -> Self {
TelemetryConfig {
metrics_enabled: true,
tracing_enabled: false,
tracing_endpoint: None,
metrics_path: "/metrics".to_string(),
health_check_path: "/health".to_string(),
system_metrics_interval: 5,
}
}
}
impl Default for ProfilingConfig {
fn default() -> Self {
ProfilingConfig {
cpu_profiling: false,
memory_profiling: false,
output_dir: PathBuf::from("./profiles"),
sample_rate: 1.0,
chrome_tracing: false,
perf_profiling: false,
}
}
}