diff --git a/bin/mpc_node.rs b/bin/mpc_node.rs index f4dcce7..692287a 100644 --- a/bin/mpc_node.rs +++ b/bin/mpc_node.rs @@ -36,13 +36,15 @@ async fn main() -> eyre::Result<()> { true, ); - StatsdBattery::init( - &service.metrics_host, - service.metrics_port, - service.metrics_queue_size, - service.metrics_buffer_size, - Some(&service.metrics_prefix), - )?; + if let Some(metrics_config) = &service.metrics { + StatsdBattery::init( + &metrics_config.host, + metrics_config.port, + metrics_config.queue_size, + metrics_config.buffer_size, + Some(&metrics_config.prefix), + )?; + } tracing_shutdown_handle } else { diff --git a/src/config.rs b/src/config.rs index 3a41c48..628a605 100644 --- a/src/config.rs +++ b/src/config.rs @@ -105,16 +105,19 @@ pub struct AwsConfig { pub struct ServiceConfig { // Service name - used for logging, metrics and tracing pub service_name: String, - // Traces pub traces_endpoint: Option, - // Metrics - pub metrics_host: String, - pub metrics_port: u16, - pub metrics_queue_size: usize, - pub metrics_buffer_size: usize, - pub metrics_prefix: String, + pub metrics: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct MetricsConfig { + pub host: String, + pub port: u16, + pub queue_size: usize, + pub buffer_size: usize, + pub prefix: String, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -132,11 +135,15 @@ mod tests { service: Some(ServiceConfig { service_name: "mpc-coordinator".to_string(), traces_endpoint: None, - metrics_host: "localhost".to_string(), - metrics_port: 8125, - metrics_queue_size: 5000, - metrics_buffer_size: 1024, - metrics_prefix: "mpc-coordinator".to_string(), + + metrics: Some(MetricsConfig { + // Metrics + host: "localhost".to_string(), + port: 8125, + queue_size: 5000, + buffer_size: 1024, + prefix: "mpc-coordinator".to_string(), + }), }), coordinator: Some(CoordinatorConfig { participants: JsonStrWrapper(vec![