From 7502528e42c4bca9c56ae6447fb8ffa3e47f1fc2 Mon Sep 17 00:00:00 2001 From: Hubert Date: Thu, 25 Jul 2024 16:30:07 +0200 Subject: [PATCH] Revert "feat(metric): add forest version to prometheus (#4535)" (#4594) --- src/metrics/mod.rs | 4 +--- src/utils/version/mod.rs | 30 ------------------------------ 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/metrics/mod.rs b/src/metrics/mod.rs index ca4f262acf83..dd9d255ae0ca 100644 --- a/src/metrics/mod.rs +++ b/src/metrics/mod.rs @@ -53,9 +53,7 @@ where warn!("Failed to register process metrics: {err}"); } - DEFAULT_REGISTRY.write().register_collector(Box::new( - crate::utils::version::ForestVersionCollector::new(), - )); + // Add the DBCollector to the registry DEFAULT_REGISTRY .write() .register_collector(Box::new(crate::metrics::db::DBCollector::new(db_directory))); diff --git a/src/utils/version/mod.rs b/src/utils/version/mod.rs index bb1de6fc4838..792525298f32 100644 --- a/src/utils/version/mod.rs +++ b/src/utils/version/mod.rs @@ -3,11 +3,6 @@ use git_version::git_version; use once_cell::sync::Lazy; -use prometheus_client::{ - collector::Collector, - encoding::{DescriptorEncoder, EncodeMetric}, - metrics::info::Info, -}; /// Current git commit hash of the Forest repository. pub const GIT_HASH: &str = @@ -20,28 +15,3 @@ pub static FOREST_VERSION_STRING: Lazy = pub static FOREST_VERSION: Lazy = Lazy::new(|| semver::Version::parse(env!("CARGO_PKG_VERSION")).expect("Invalid version")); - -#[derive(Debug)] -pub struct ForestVersionCollector { - version: Info>, -} - -impl ForestVersionCollector { - pub fn new() -> Self { - let version = Info::new(vec![("version", FOREST_VERSION_STRING.as_str())]); - Self { version } - } -} - -impl Collector for ForestVersionCollector { - fn encode(&self, mut encoder: DescriptorEncoder) -> Result<(), std::fmt::Error> { - let metric_encoder = encoder.encode_descriptor( - "forest_version", - "semantic version of the forest binary", - None, - self.version.metric_type(), - )?; - self.version.encode(metric_encoder)?; - Ok(()) - } -}