reth_node_metrics/
version.rs

1//! This exposes reth's version information over prometheus.
2use metrics::gauge;
3
4/// Contains version information for the application.
5#[derive(Debug, Clone)]
6pub struct VersionInfo {
7    /// The version of the application.
8    pub version: &'static str,
9    /// The build timestamp of the application.
10    pub build_timestamp: &'static str,
11    /// The cargo features enabled for the build.
12    pub cargo_features: &'static str,
13    /// The Git SHA of the build.
14    pub git_sha: &'static str,
15    /// The target triple for the build.
16    pub target_triple: &'static str,
17    /// The build profile (e.g., debug or release).
18    pub build_profile: &'static str,
19}
20
21impl VersionInfo {
22    /// This exposes reth's version information over prometheus.
23    pub fn register_version_metrics(&self) {
24        let labels: [(&str, &str); 6] = [
25            ("version", self.version),
26            ("build_timestamp", self.build_timestamp),
27            ("cargo_features", self.cargo_features),
28            ("git_sha", self.git_sha),
29            ("target_triple", self.target_triple),
30            ("build_profile", self.build_profile),
31        ];
32
33        let _gauge = gauge!("info", &labels);
34    }
35}