From d4736006ec3d6024ec6d7c96c62c42dd04271107 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 6 Jan 2025 14:31:49 +0100 Subject: [PATCH 1/4] fix: configure metrics compilation in root toml Subcrates would previously enable metrics by default instead of exposing them as a feature. --- Cargo.toml | 2 +- cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e4da41f80..c0d196ef0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ name = "snarkos" path = "snarkos/main.rs" [features] -metrics = [ "snarkos-node-metrics", "snarkos-node/metrics" ] +default = [ "snarkos-node-metrics", "snarkos-node/metrics", "snarkos-cli/metrics" ] history = [ "snarkos-node/history" ] test_targets = [ "snarkos-cli/test_targets" ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 6dd5f12238..ae37d179f8 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -17,7 +17,7 @@ license = "Apache-2.0" edition = "2021" [features] -default = [ "snarkos-node/metrics" ] +metrics = [ "snarkos-node/metrics" ] test_targets = [ "snarkvm/test_targets" ] [dependencies.aleo-std] From 11f96f184b8f23943e979baa6eae3de38e94833c Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 6 Jan 2025 14:40:24 +0100 Subject: [PATCH 2/4] deps(cli): make metrics an optional dependency --- cli/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index ae37d179f8..be61eed43a 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -17,7 +17,7 @@ license = "Apache-2.0" edition = "2021" [features] -metrics = [ "snarkos-node/metrics" ] +metrics = [ "dep:metrics", "snarkos-node/metrics" ] test_targets = [ "snarkvm/test_targets" ] [dependencies.aleo-std] @@ -50,6 +50,7 @@ features = [ "serde", "rayon" ] package = "snarkos-node-metrics" path = "../node/metrics" version = "=3.2.0" +optional = true [dependencies.num_cpus] version = "1" From de95a3c670fecf3dbe2895affa776647845a1b1c Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 6 Jan 2025 16:24:54 +0100 Subject: [PATCH 3/4] chore: fix tcp deps formatting --- node/tcp/Cargo.toml | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/node/tcp/Cargo.toml b/node/tcp/Cargo.toml index eb42bfea5e..7054e2fd35 100644 --- a/node/tcp/Cargo.toml +++ b/node/tcp/Cargo.toml @@ -25,31 +25,31 @@ async-trait = "0.1" bytes = "1" parking_lot = "0.12" - [dependencies.futures-util] - version = "0.3" - features = [ "sink" ] - - [dependencies.metrics] - package = "snarkos-node-metrics" - path = "../metrics" - version = "=3.2.0" - optional = true - - [dependencies.once_cell] - version = "1" - features = [ "parking_lot" ] - - [dependencies.tokio] - version = "1.28" - features = [ "io-util", "net", "parking_lot", "rt", "sync", "time" ] - - [dependencies.tokio-util] - version = "0.7" - features = [ "codec" ] - - [dependencies.tracing] - version = "0.1" - default-features = false +[dependencies.futures-util] +version = "0.3" +features = [ "sink" ] + +[dependencies.metrics] +package = "snarkos-node-metrics" +path = "../metrics" +version = "=3.2.0" +optional = true + +[dependencies.once_cell] +version = "1" +features = [ "parking_lot" ] + +[dependencies.tokio] +version = "1.28" +features = [ "io-util", "net", "parking_lot", "rt", "sync", "time" ] + +[dependencies.tokio-util] +version = "0.7" +features = [ "codec" ] + +[dependencies.tracing] +version = "0.1" +default-features = false [dev-dependencies.tokio] version = "1.28" From c2795e19cc5766da1a189c8c9689c471f379bf3a Mon Sep 17 00:00:00 2001 From: Niklas Long Date: Tue, 21 Jan 2025 09:34:34 +0100 Subject: [PATCH 4/4] fix: adjust cli metrics feature flagging --- cli/src/commands/start.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index d0ddc6cc6d..056cb472c3 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -137,9 +137,11 @@ pub struct Start { pub logfile: PathBuf, /// Enables the metrics exporter + #[cfg(feature = "metrics")] #[clap(default_value = "false", long = "metrics")] pub metrics: bool, /// Specify the IP address and port for the metrics exporter + #[cfg(feature = "metrics")] #[clap(long = "metrics-ip")] pub metrics_ip: Option, @@ -587,6 +589,7 @@ impl Start { crate::helpers::check_validator_machine(node_type); // Initialize the metrics. + #[cfg(feature = "metrics")] if self.metrics { metrics::initialize_metrics(self.metrics_ip); }