diff --git a/justfile b/justfile index 9235aa355..a48c8ffd6 100644 --- a/justfile +++ b/justfile @@ -372,7 +372,7 @@ e2e-relayer-external-up: wait-service --tcp 0.0.0.0:5432 -t {{ wait_service_timeout }} -- echo # Start Stratus binary - cargo run --release --bin stratus --no-default-features --features "dev,rocks,kubernetes" -- --enable-test-accounts --block-mode 1s --perm-storage=rocks --relayer-db-url "postgres://postgres:123@localhost:5432/stratus" --relayer-db-connections 5 --relayer-db-timeout 1s -a 0.0.0.0:3000 > e2e_logs/stratus.log & + cargo run --release --bin stratus --features dev -- --enable-test-accounts --block-mode 1s --perm-storage=rocks --relayer-db-url "postgres://postgres:123@localhost:5432/stratus" --relayer-db-connections 5 --relayer-db-timeout 1s -a 0.0.0.0:3000 > e2e_logs/stratus.log & # Wait for Stratus to start wait-service --tcp 0.0.0.0:3000 -t {{ wait_service_timeout }} -- echo @@ -391,7 +391,7 @@ e2e-relayer-external-up: sleep 5 # Start Relayer External binary - cargo run --release --bin relayer --no-default-features --features "rocks,kubernetes" -- --db-url postgres://postgres:123@localhost:5432/stratus --db-connections 5 --db-timeout 1s --forward-to http://localhost:8545 --backoff 10ms --tokio-console-address 0.0.0.0:6979 > e2e_logs/relayer.log & + cargo run --release --bin relayer --features dev -- --db-url postgres://postgres:123@localhost:5432/stratus --db-connections 5 --db-timeout 1s --forward-to http://localhost:8545 --backoff 10ms --tokio-console-address 0.0.0.0:6979 --metrics-exporter-address 0.0.0.0:9001 > e2e_logs/relayer.log & if [ -d e2e ]; then ( diff --git a/src/config.rs b/src/config.rs index 53488cfd8..947fdf0ab 100644 --- a/src/config.rs +++ b/src/config.rs @@ -98,6 +98,10 @@ pub struct CommonConfig { // Address for the Tokio Console #[arg(long = "tokio-console-address", env = "TOKIO_CONSOLE_ADDRESS", default_value = "0.0.0.0:6669")] pub tokio_console_address: SocketAddr, + + // Address for the Prometheus Metrics Exporter + #[arg(long = "metrics-exporter-address", env = "METRICS_EXPORTER_ADDRESS", default_value = "0.0.0.0:9000")] + pub metrics_exporter_address: SocketAddr, } impl WithCommonConfig for CommonConfig { diff --git a/src/globals.rs b/src/globals.rs index 3bd58ca4b..687d49045 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -47,7 +47,7 @@ where // init metrics #[cfg(feature = "metrics")] - infra::init_metrics(config.common().metrics_histogram_kind); + infra::init_metrics(config.common().metrics_exporter_address, config.common().metrics_histogram_kind); // init sentry let _sentry_guard = config.common().sentry_url.as_ref().map(|sentry_url| infra::init_sentry(sentry_url)); diff --git a/src/infra/metrics/metrics_init.rs b/src/infra/metrics/metrics_init.rs index be59de8f1..d0221c080 100644 --- a/src/infra/metrics/metrics_init.rs +++ b/src/infra/metrics/metrics_init.rs @@ -1,6 +1,7 @@ //! Metrics services. #![cfg(feature = "metrics")] +use std::net::SocketAddr; use std::stringify; use metrics_exporter_prometheus::Matcher; @@ -29,7 +30,7 @@ const BUCKET_FOR_DURATION: [f64; 37] = [ /// Init application global metrics. /// /// Default configuration runs metrics exporter on port 9000. -pub fn init_metrics(histogram_kind: MetricsHistogramKind) { +pub fn init_metrics(metrics_exporter_address: SocketAddr, histogram_kind: MetricsHistogramKind) { tracing::info!("creating metrics exporter"); // get metric definitions @@ -45,7 +46,7 @@ pub fn init_metrics(histogram_kind: MetricsHistogramKind) { metrics.extend(metrics_for_external_relayer()); // init exporter - let mut builder = PrometheusBuilder::new(); + let mut builder = PrometheusBuilder::new().with_http_listener(metrics_exporter_address); // init buckets if histogram_kind == MetricsHistogramKind::Histogram {