Skip to content

Commit

Permalink
Update the initialization of the metrics component
Browse files Browse the repository at this point in the history
Make it compatible with the new version of `metrics`.
  • Loading branch information
jvff committed Oct 21, 2021
1 parent 9212ed9 commit 2dec967
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions zebrad/src/components/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@ impl MetricsEndpoint {
// We manually expand the metrics::increment!() macro because it only
// supports string literals for metrics names, preventing us from
// using concat!() to build the name.
static METRIC_NAME: [metrics::SharedString; 2] = [
metrics::SharedString::const_str(env!("CARGO_PKG_NAME")),
metrics::SharedString::const_str("build.info"),
];
static METRIC_NAME: &str = concat!(env!("CARGO_PKG_NAME"), ".build.info");
static METRIC_LABELS: [metrics::Label; 1] =
[metrics::Label::from_static_parts(
"version",
env!("CARGO_PKG_VERSION"),
)];
static METRIC_KEY: metrics::KeyData =
metrics::KeyData::from_static_parts(&METRIC_NAME, &METRIC_LABELS);
static METRIC_KEY: metrics::Key =
metrics::Key::from_static_parts(METRIC_NAME, &METRIC_LABELS);
if let Some(recorder) = metrics::try_recorder() {
recorder.increment_counter(metrics::Key::Borrowed(&METRIC_KEY), 1);
recorder.increment_counter(&METRIC_KEY, 1);
}
}
Err(e) => panic!(
Expand Down

0 comments on commit 2dec967

Please sign in to comment.