Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tracing/metrics): optional metrics #57

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading