Skip to content

Commit

Permalink
make metrics optional
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Feb 27, 2024
1 parent 09bfe0c commit ae977b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
16 changes: 9 additions & 7 deletions bin/mpc_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
31 changes: 19 additions & 12 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

// 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<MetricsConfig>,
}

#[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)]
Expand All @@ -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![
Expand Down

0 comments on commit ae977b2

Please sign in to comment.