codex_convert_proxy/
telemetry.rs1use tracing::info;
6
7#[derive(Debug, Clone)]
9pub struct TelemetryConfig {
10 pub enabled: bool,
12 pub endpoint: String,
14 pub service_name: String,
16 pub sample_rate: f64,
18}
19
20impl Default for TelemetryConfig {
21 fn default() -> Self {
22 Self {
23 enabled: false,
24 endpoint: "http://localhost:4317".to_string(),
25 service_name: "codex-convert-proxy".to_string(),
26 sample_rate: 1.0,
27 }
28 }
29}
30
31pub fn init_telemetry(config: &TelemetryConfig) -> anyhow::Result<()> {
34 if !config.enabled {
35 info!("Telemetry disabled");
36 return Ok(());
37 }
38
39 info!(
40 "Telemetry configured: endpoint={}, service={}",
41 config.endpoint, config.service_name
42 );
43
44 Ok(())
49}
50
51pub fn shutdown_telemetry() {
53 }
57
58#[cfg(test)]
59mod tests {
60 use super::*;
61
62 #[test]
63 fn test_default_config() {
64 let config = TelemetryConfig::default();
65 assert!(!config.enabled);
66 assert_eq!(config.endpoint, "http://localhost:4317");
67 assert_eq!(config.service_name, "codex-convert-proxy");
68 assert_eq!(config.sample_rate, 1.0);
69 }
70}