Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

sc-consensus-beefy: fix metrics: use correct names #13494

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions client/consensus/beefy/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

//! BEEFY Prometheus metrics definition

use log::debug;
use log::{debug, error};
use prometheus::{register, Counter, Gauge, PrometheusError, Registry, U64};

/// Helper trait for registering BEEFY metrics to Prometheus registry.
Expand Down Expand Up @@ -129,13 +129,13 @@ impl PrometheusRegister for VoterMetrics {
)?,
beefy_equivocation_votes: register(
Counter::new(
"substrate_beefy_stale_votes",
"substrate_beefy_equivocation_votes",
"Number of equivocation votes received",
)?,
registry,
)?,
beefy_invalid_votes: register(
Counter::new("substrate_beefy_stale_votes", "Number of invalid votes received")?,
Counter::new("substrate_beefy_invalid_votes", "Number of invalid votes received")?,
registry,
)?,
beefy_stale_votes: register(
Expand Down Expand Up @@ -200,14 +200,14 @@ impl PrometheusRegister for BlockImportMetrics {
beefy_good_justification_imports: register(
Counter::new(
"substrate_beefy_good_justification_imports",
"Number of Good Justification imports",
"Number of good justifications on block-import",
)?,
registry,
)?,
beefy_bad_justification_imports: register(
Counter::new(
"substrate_beefy_bad_justification_imports",
"Number of Bad Justification imports",
"Number of bad justifications on block-import",
)?,
registry,
)?,
Expand Down Expand Up @@ -313,7 +313,7 @@ pub(crate) fn register_metrics<T: PrometheusRegister>(
Some(metrics)
},
Err(err) => {
debug!(target: "beefy", "🥩 Failed to register {} metrics: {:?}", T::DESCRIPTION, err);
error!(target: "beefy", "🥩 Failed to register {} metrics: {:?}", T::DESCRIPTION, err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error!(target: "beefy", "🥩 Failed to register {} metrics: {:?}", T::DESCRIPTION, err);
error!(target: LOG_TARGET, "🥩 Failed to register {} metrics: {:?}", T::DESCRIPTION, err);

None
},
})
Expand Down Expand Up @@ -347,3 +347,17 @@ macro_rules! metric_get {
$self.metrics.as_ref().map(|metrics| metrics.$m.clone())
}};
}

#[cfg(test)]
pub(crate) mod tests {
use super::*;

#[test]
fn should_register_metrics() {
let registry = Some(Registry::new());
assert!(register_metrics::<VoterMetrics>(registry.clone()).is_some());
assert!(register_metrics::<BlockImportMetrics>(registry.clone()).is_some());
assert!(register_metrics::<OnDemandIncomingRequestsMetrics>(registry.clone()).is_some());
assert!(register_metrics::<OnDemandOutgoingRequestsMetrics>(registry.clone()).is_some());
}
}