Skip to content

Commit

Permalink
Revert "feat(metric): add forest version to prometheus (#4535)" (#4594)
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs authored Jul 25, 2024
1 parent a5688c8 commit 7502528
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
4 changes: 1 addition & 3 deletions src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
30 changes: 0 additions & 30 deletions src/utils/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -20,28 +15,3 @@ pub static FOREST_VERSION_STRING: Lazy<String> =

pub static FOREST_VERSION: Lazy<semver::Version> =
Lazy::new(|| semver::Version::parse(env!("CARGO_PKG_VERSION")).expect("Invalid version"));

#[derive(Debug)]
pub struct ForestVersionCollector {
version: Info<Vec<(&'static str, &'static str)>>,
}

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(())
}
}

0 comments on commit 7502528

Please sign in to comment.