mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add prometheus support (#474)
This commit is contained in:
committed by
GitHub
parent
c1f124d3e3
commit
4da574df84
@ -38,3 +38,5 @@ serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
walkdir = "2.3"
|
||||
futures = "0.3.25"
|
||||
metrics-exporter-prometheus = { version = "0.11.0", features = ["http-listener"] }
|
||||
metrics-util = "0.14.0"
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
//! CLI definition and entrypoint to executable
|
||||
|
||||
use clap::{ArgAction, Parser, Subcommand};
|
||||
use metrics_exporter_prometheus::PrometheusBuilder;
|
||||
use metrics_util::layers::{PrefixLayer, Stack};
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
||||
use crate::{
|
||||
@ -16,6 +18,16 @@ pub async fn run() -> eyre::Result<()> {
|
||||
|
||||
reth_tracing::build_subscriber(tracing).init();
|
||||
|
||||
if opt.metrics {
|
||||
let (recorder, exporter) =
|
||||
PrometheusBuilder::new().build().expect("couldn't build Prometheus");
|
||||
tokio::task::spawn(exporter);
|
||||
Stack::new(recorder)
|
||||
.push(PrefixLayer::new("reth"))
|
||||
.install()
|
||||
.expect("couldn't install metrics recorder");
|
||||
}
|
||||
|
||||
match opt.command {
|
||||
Commands::Node(command) => command.execute().await,
|
||||
Commands::TestEthChain(command) => command.execute().await,
|
||||
@ -51,4 +63,7 @@ struct Cli {
|
||||
/// Silence all output
|
||||
#[clap(long, global = true)]
|
||||
silent: bool,
|
||||
|
||||
#[clap(long, global = true)]
|
||||
metrics: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user