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

Add metrics config option #734

Merged
merged 10 commits into from
Oct 28, 2022
Merged
3 changes: 3 additions & 0 deletions fuel-block-executor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
pub struct Config {
/// Print execution backtraces if transaction execution reverts.
pub backtrace: bool,

/// Enables prometheus metrics for this fuel-service
pub metrics: bool,
}
4 changes: 3 additions & 1 deletion fuel-block-importer/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#[derive(Default, Debug, Clone)]
pub struct Config {}
pub struct Config {
pub metrics: bool,
}
1 change: 1 addition & 0 deletions fuel-block-producer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ use fuel_core_interfaces::common::fuel_tx::Address;
pub struct Config {
pub utxo_validation: bool,
pub coinbase_recipient: Address,
pub metrics: bool,
}
1 change: 1 addition & 0 deletions fuel-block-producer/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ async fn block_producer() -> Result<()> {
config: fuel_block_producer::config::Config {
utxo_validation: true,
coinbase_recipient: Address::default(),
metrics: false,
},
db: Box::new(mock_db.clone()),
txpool: Box::new(TxPoolAdapter {
Expand Down
6 changes: 6 additions & 0 deletions fuel-core/src/cli/run.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unused_variables)]
use crate::{
cli::DEFAULT_DB_PATH,
FuelService,
Expand Down Expand Up @@ -110,6 +111,9 @@ pub struct Command {
#[cfg(feature = "p2p")]
#[clap(flatten)]
pub p2p_args: p2p::P2pArgs,

#[clap(long = "metrics")]
pub metrics: bool,
}

impl Command {
Expand All @@ -131,6 +135,7 @@ impl Command {
relayer_args,
#[cfg(feature = "p2p")]
p2p_args,
metrics,
} = self;

let addr = net::SocketAddr::new(ip, port);
Expand Down Expand Up @@ -190,6 +195,7 @@ impl Command {
block_producer: fuel_block_producer::Config {
utxo_validation,
coinbase_recipient,
metrics: false,
},
block_executor: Default::default(),
#[cfg(feature = "relayer")]
Expand Down
1 change: 1 addition & 0 deletions fuel-core/src/cli/run/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ impl From<P2pArgs> for anyhow::Result<P2PConfig> {
set_connection_keep_alive: Duration::from_secs(args.connection_keep_alive),
info_interval: Some(Duration::from_secs(args.info_interval)),
identify_interval: Some(Duration::from_secs(args.identify_interval)),
metrics: false,
})
}
}
1 change: 1 addition & 0 deletions fuel-core/src/cli/run/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl From<RelayerArgs> for Config {
sync_minimum_duration: Duration::from_secs(args.sync_minimum_duration_secs),
syncing_call_frequency: Duration::from_secs(args.syncing_call_frequency_secs),
syncing_log_frequency: Duration::from_secs(args.syncing_log_frequency_secs),
metrics: false,
}
}
}
1 change: 1 addition & 0 deletions fuel-core/src/service/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub async fn start_modules(config: &Config, database: &Database) -> Result<Modul
trigger: *trigger,
block_gas_limit: config.chain_conf.block_gas_limit,
signing_key: config.consensus_key.clone(),
metrics: false,
}),
),
// TODO: enable when bft config is ready to use
Expand Down
4 changes: 4 additions & 0 deletions fuel-p2p/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ pub struct P2PConfig {
pub set_request_timeout: Duration,
/// Sets the keep-alive timeout of idle connections.
pub set_connection_keep_alive: Duration,

/// Enables prometheus metrics for this fuel-service
pub metrics: bool,
}

/// Takes secret key bytes generated outside of libp2p.
Expand Down Expand Up @@ -126,6 +129,7 @@ impl P2PConfig {
set_connection_keep_alive: REQ_RES_TIMEOUT,
info_interval: Some(Duration::from_secs(3)),
identify_interval: Some(Duration::from_secs(5)),
metrics: false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions fuel-poa-coordinator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Config {
pub trigger: Trigger,
pub block_gas_limit: Word,
pub signing_key: Option<Secret<SecretKeyWrapper>>,
pub metrics: bool,
}

/// Block production trigger for PoA operation
Expand Down
7 changes: 7 additions & 0 deletions fuel-poa-coordinator/tests/test_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ async fn clean_startup_shutdown_each_trigger() -> anyhow::Result<()> {
trigger,
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down Expand Up @@ -425,6 +426,7 @@ async fn never_trigger_never_produces_blocks() -> anyhow::Result<()> {
trigger: Trigger::Never,
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (mut txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down Expand Up @@ -470,6 +472,7 @@ async fn instant_trigger_produces_block_instantly() -> anyhow::Result<()> {
trigger: Trigger::Instant,
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (mut txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down Expand Up @@ -532,6 +535,7 @@ async fn interval_trigger_produces_blocks_periodically() -> anyhow::Result<()> {
},
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (mut txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down Expand Up @@ -625,6 +629,7 @@ async fn interval_trigger_doesnt_react_to_full_txpool() -> anyhow::Result<()> {
},
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (mut txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down Expand Up @@ -683,6 +688,7 @@ async fn hybrid_trigger_produces_blocks_correctly() -> anyhow::Result<()> {
},
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (mut txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down Expand Up @@ -763,6 +769,7 @@ async fn hybrid_trigger_reacts_correctly_to_full_txpool() -> anyhow::Result<()>
},
block_gas_limit: 100_000,
signing_key: Some(test_signing_key()),
metrics: false,
});

let (mut txpool, broadcast_rx) = MockTxPool::spawn();
Expand Down
4 changes: 4 additions & 0 deletions fuel-relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct Config {
/// How often progress logs are printed when the DA node is
/// syncing.
pub syncing_log_frequency: Duration,

/// Enables metrics on this fuel service
pub metrics: bool,
}

#[allow(missing_docs)]
Expand All @@ -62,6 +65,7 @@ impl Default for Config {
sync_minimum_duration: Self::DEFAULT_SYNC_MINIMUM_DURATION,
syncing_call_frequency: Self::DEFAULT_SYNCING_CALL_FREQ,
syncing_log_frequency: Self::DEFAULT_SYNCING_LOG_FREQ,
metrics: false,
}
}
}
4 changes: 4 additions & 0 deletions fuel-txpool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub struct Config {
pub utxo_validation: bool,
/// chain config
pub chain_config: ChainConfig,

/// Enables prometheus metrics for this fuel-service
pub metrics: bool,
}

impl Default for Config {
Expand All @@ -22,6 +25,7 @@ impl Default for Config {
min_gas_price: 0,
utxo_validation: true,
chain_config: ChainConfig::default(),
metrics: false,
}
}
}