Skip to content

Commit

Permalink
Unify metrics CLI arguments on subspace-farmer and `subspace-bootst…
Browse files Browse the repository at this point in the history
…rap-node` with `subspace-node`
  • Loading branch information
nazar-pc committed Feb 8, 2024
1 parent c9c9d21 commit 5689621
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions crates/subspace-farmer/src/bin/subspace-farmer/commands/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ pub(crate) struct FarmingArgs {
no_info: bool,
/// Defines endpoints for the prometheus metrics server. It doesn't start without at least
/// one specified endpoint. Format: 127.0.0.1:8080
#[arg(long, alias = "metrics-endpoint")]
metrics_endpoints: Vec<SocketAddr>,
#[arg(long, aliases = ["metrics-endpoint", "metrics-endpoints"])]
prometheus_listen_on: Vec<SocketAddr>,
/// Defines how many sectors farmer will download concurrently, allows to limit memory usage of
/// the plotting process, defaults to `--sector-encoding-concurrency` + 1 to download future
/// sector ahead of time
Expand Down Expand Up @@ -314,7 +314,7 @@ where
dev,
tmp,
mut disk_farms,
metrics_endpoints,
prometheus_listen_on,
sector_downloading_concurrency,
sector_encoding_concurrency,
farm_during_initial_plotting,
Expand Down Expand Up @@ -384,7 +384,7 @@ where
// Metrics
let mut prometheus_metrics_registry = Registry::default();
let farmer_metrics = FarmerMetrics::new(&mut prometheus_metrics_registry);
let metrics_endpoints_are_specified = !metrics_endpoints.is_empty();
let should_start_prometheus_server = !prometheus_listen_on.is_empty();

let (node, mut node_runner) = {
if dsn.bootstrap_nodes.is_empty() {
Expand All @@ -399,13 +399,13 @@ where
Arc::downgrade(&readers_and_pieces),
node_client.clone(),
piece_cache.clone(),
metrics_endpoints_are_specified.then_some(&mut prometheus_metrics_registry),
should_start_prometheus_server.then_some(&mut prometheus_metrics_registry),
)?
};

let _prometheus_worker = if metrics_endpoints_are_specified {
let _prometheus_worker = if should_start_prometheus_server {
let prometheus_task = start_prometheus_metrics_server(
metrics_endpoints,
prometheus_listen_on,
RegistryAdapter::PrometheusClient(prometheus_metrics_registry),
)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ enum Command {
external_addresses: Vec<Multiaddr>,
/// Defines endpoints for the prometheus metrics server. It doesn't start without at least
/// one specified endpoint. Format: 127.0.0.1:8080
#[arg(long, alias = "metrics-endpoint")]
metrics_endpoints: Vec<SocketAddr>,
#[arg(long, aliases = ["metrics-endpoint", "metrics-endpoints"])]
prometheus_listen_on: Vec<SocketAddr>,
},
/// Generate a new keypair
GenerateKeypair {
Expand Down Expand Up @@ -149,7 +149,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
allow_private_ips,
protocol_version,
external_addresses,
metrics_endpoints,
prometheus_listen_on,
} => {
debug!(
"Libp2p protocol stack instantiated with version: {} ",
Expand All @@ -160,10 +160,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
let keypair = identity::Keypair::from(decoded_keypair);

// Metrics
let metrics_endpoints_are_specified = !metrics_endpoints.is_empty();
let should_start_prometheus_server = !prometheus_listen_on.is_empty();
let mut metrics_registry = Registry::default();
let dsn_metrics_registry =
metrics_endpoints_are_specified.then_some(&mut metrics_registry);
should_start_prometheus_server.then_some(&mut metrics_registry);

let known_peers_registry_config = KnownPeersManagerConfig {
enable_known_peers_source: false,
Expand Down Expand Up @@ -217,10 +217,10 @@ async fn main() -> Result<(), Box<dyn Error>> {

info!("Subspace Bootstrap Node started");

let prometheus_task = metrics_endpoints_are_specified
let prometheus_task = should_start_prometheus_server
.then(|| {
start_prometheus_metrics_server(
metrics_endpoints,
prometheus_listen_on,
RegistryAdapter::PrometheusClient(metrics_registry),
)
})
Expand Down

0 comments on commit 5689621

Please sign in to comment.