Skip to content

Commit 6b3c394

Browse files
apollo_network_benchmark: setup Prometheus metrics exporter
1 parent 790ee1a commit 6b3c394

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_network_benchmark/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ testing = []
1111
[dependencies]
1212
clap = { workspace = true, features = ["derive", "env"] }
1313
lazy_static.workspace = true
14+
metrics-exporter-prometheus.workspace = true
1415
tokio = { workspace = true, features = ["full", "sync"] }
1516
tracing.workspace = true
1617
tracing-subscriber.workspace = true

crates/apollo_network_benchmark/src/bin/broadcast_network_stress_test_node/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Runs a node that stress tests the p2p communication of the network.
2+
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
23

34
use clap::Parser;
5+
use metrics_exporter_prometheus::PrometheusBuilder;
46
use tracing::Level;
57

68
#[cfg(test)]
@@ -29,5 +31,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2931

3032
println!("Starting network stress test with args:\n{args:?}");
3133

34+
// Set up metrics
35+
let builder = PrometheusBuilder::new().with_http_listener(SocketAddr::V4(SocketAddrV4::new(
36+
Ipv4Addr::UNSPECIFIED,
37+
args.runner.metric_port,
38+
)));
39+
40+
builder.install().expect("Failed to install prometheus recorder/exporter");
41+
3242
Ok(())
3343
}

crates/apollo_network_benchmark/src/node_args.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ use clap::Parser;
33
#[derive(Parser, Debug, Clone)]
44
#[command(version, about, long_about = None)]
55
/// Arguments from the runner, not meant to be set by the user.
6-
pub struct RunnerArgs {}
6+
pub struct RunnerArgs {
7+
/// The port to run the Prometheus metrics server on
8+
#[arg(long, env)]
9+
pub metric_port: u16,
10+
}
711

812
#[derive(Parser, Debug, Clone)]
913
#[command(version, about, long_about = None)]

0 commit comments

Comments
 (0)