Skip to content

Commit

Permalink
Merge pull request #3462 from niklaslong/fix/3379-metrics-feature
Browse files Browse the repository at this point in the history
[Fix] Configure metrics compilation in root toml
  • Loading branch information
vicsn authored Jan 27, 2025
2 parents f188d37 + c2795e1 commit e422b9a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]

Expand Down
3 changes: 2 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "Apache-2.0"
edition = "2021"

[features]
default = [ "snarkos-node/metrics" ]
metrics = [ "dep:metrics", "snarkos-node/metrics" ]
test_targets = [ "snarkvm/test_targets" ]

[dependencies.aleo-std]
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SocketAddr>,

Expand Down Expand Up @@ -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);
}
Expand Down
50 changes: 25 additions & 25 deletions node/tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e422b9a

Please sign in to comment.