mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-09 23:38:10 -05:00
feat: expose version information over prometheus (#6195)
This commit is contained in:
@@ -14,11 +14,14 @@ pub mod dirs;
|
||||
pub mod engine_api_store;
|
||||
pub mod events;
|
||||
pub mod init;
|
||||
pub mod metrics;
|
||||
pub mod node_config;
|
||||
pub mod prometheus_exporter;
|
||||
pub mod utils;
|
||||
pub mod version;
|
||||
|
||||
// Re-export for backwards compatibility.
|
||||
pub use metrics::prometheus_exporter;
|
||||
|
||||
/// Re-exported from `reth_primitives`.
|
||||
pub mod primitives {
|
||||
pub use reth_primitives::*;
|
||||
|
||||
4
crates/node-core/src/metrics/mod.rs
Normal file
4
crates/node-core/src/metrics/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
//! Metrics utilities for the node.
|
||||
|
||||
pub mod prometheus_exporter;
|
||||
pub mod version_metrics;
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Prometheus exporter
|
||||
|
||||
use crate::metrics::version_metrics::register_version_metrics;
|
||||
use eyre::WrapErr;
|
||||
use hyper::{
|
||||
service::{make_service_fn, service_fn},
|
||||
@@ -104,6 +105,7 @@ where
|
||||
process.describe();
|
||||
describe_memory_stats();
|
||||
describe_io_stats();
|
||||
register_version_metrics();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
18
crates/node-core/src/metrics/version_metrics.rs
Normal file
18
crates/node-core/src/metrics/version_metrics.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
//! This exposes reth's version information over prometheus.
|
||||
|
||||
use crate::version::build_profile_name;
|
||||
use metrics::register_gauge;
|
||||
|
||||
const LABELS: [(&str, &str); 6] = [
|
||||
("version", env!("CARGO_PKG_VERSION")),
|
||||
("build_timestamp", env!("VERGEN_BUILD_TIMESTAMP")),
|
||||
("cargo_features", env!("VERGEN_CARGO_FEATURES")),
|
||||
("git_sha", env!("VERGEN_GIT_SHA")),
|
||||
("target_triple", env!("VERGEN_CARGO_TARGET_TRIPLE")),
|
||||
("build_profile", build_profile_name()),
|
||||
];
|
||||
|
||||
/// This exposes reth's version information over prometheus.
|
||||
pub fn register_version_metrics() {
|
||||
register_gauge!("info", &LABELS);
|
||||
}
|
||||
@@ -16,7 +16,7 @@ use crate::{
|
||||
engine_api_store::EngineApiStore,
|
||||
events,
|
||||
init::init_genesis,
|
||||
prometheus_exporter,
|
||||
metrics::prometheus_exporter,
|
||||
utils::{get_single_header, write_peers_to_file},
|
||||
version::SHORT_VERSION,
|
||||
};
|
||||
|
||||
@@ -79,7 +79,7 @@ pub fn default_extradata() -> String {
|
||||
format!("reth/v{}/{}", env!("CARGO_PKG_VERSION"), std::env::consts::OS)
|
||||
}
|
||||
|
||||
const fn build_profile_name() -> &'static str {
|
||||
pub(crate) const fn build_profile_name() -> &'static str {
|
||||
// Derived from https://stackoverflow.com/questions/73595435/how-to-get-profile-from-cargo-toml-in-build-rs-or-at-runtime
|
||||
// We split on the path separator of the *host* machine, which may be different from
|
||||
// `std::path::MAIN_SEPARATOR_STR`.
|
||||
|
||||
Reference in New Issue
Block a user