Unify metric names (#1209)

* unify metric names

* refactor standalone metrics

* headers sync metrics

* post-merge fix

* fix compilation

* fmt

* fix dashboards

* fix local dashboards

* update Rococo/Wococo runtime version

* remove commented code

* fixed grumbles

* fmt

* fixed widget names
This commit is contained in:
Svyatoslav Nikolsky
2021-11-22 15:38:42 +03:00
committed by Bastian Köcher
parent 940d7e463b
commit bbf8b51f9c
33 changed files with 509 additions and 515 deletions
@@ -20,7 +20,8 @@ use async_std::sync::{Arc, RwLock};
use async_trait::async_trait;
use codec::Decode;
use relay_utils::metrics::{
metric_name, register, F64SharedRef, Gauge, PrometheusError, Registry, StandaloneMetrics, F64,
metric_name, register, F64SharedRef, Gauge, Metric, PrometheusError, Registry,
StandaloneMetric, F64,
};
use sp_core::storage::StorageKey;
use sp_runtime::{traits::UniqueSaturatedInto, FixedPointNumber};
@@ -42,8 +43,6 @@ pub struct FloatStorageValueMetric<C: Chain, T: Clone> {
impl<C: Chain, T: Decode + FixedPointNumber> FloatStorageValueMetric<C, T> {
/// Create new metric.
pub fn new(
registry: &Registry,
prefix: Option<&str>,
client: Client<C>,
storage_key: StorageKey,
maybe_default_value: Option<T>,
@@ -55,7 +54,7 @@ impl<C: Chain, T: Decode + FixedPointNumber> FloatStorageValueMetric<C, T> {
client,
storage_key,
maybe_default_value,
metric: register(Gauge::new(metric_name(prefix, &name), help)?, registry)?,
metric: Gauge::new(metric_name(None, &name), help)?,
shared_value_ref,
})
}
@@ -66,8 +65,17 @@ impl<C: Chain, T: Decode + FixedPointNumber> FloatStorageValueMetric<C, T> {
}
}
impl<C: Chain, T> Metric for FloatStorageValueMetric<C, T>
where
T: 'static + Decode + Send + Sync + FixedPointNumber,
{
fn register(&self, registry: &Registry) -> Result<(), PrometheusError> {
register(self.metric.clone(), registry).map(drop)
}
}
#[async_trait]
impl<C: Chain, T> StandaloneMetrics for FloatStorageValueMetric<C, T>
impl<C: Chain, T> StandaloneMetric for FloatStorageValueMetric<C, T>
where
T: 'static + Decode + Send + Sync + FixedPointNumber,
{
@@ -18,7 +18,7 @@ use crate::{chain::Chain, client::Client, error::Error};
use async_trait::async_trait;
use relay_utils::metrics::{
metric_name, register, Gauge, PrometheusError, Registry, StandaloneMetrics, U64,
metric_name, register, Gauge, Metric, PrometheusError, Registry, StandaloneMetric, U64,
};
use sp_core::storage::StorageKey;
use sp_runtime::traits::Header as HeaderT;
@@ -46,16 +46,10 @@ impl<C: Chain> Clone for StorageProofOverheadMetric<C> {
impl<C: Chain> StorageProofOverheadMetric<C> {
/// Create new metric instance with given name and help.
pub fn new(
registry: &Registry,
prefix: Option<&str>,
client: Client<C>,
name: String,
help: String,
) -> Result<Self, PrometheusError> {
pub fn new(client: Client<C>, name: String, help: String) -> Result<Self, PrometheusError> {
Ok(StorageProofOverheadMetric {
client,
metric: register(Gauge::new(metric_name(prefix, &name), help)?, registry)?,
metric: Gauge::new(metric_name(None, &name), help)?,
})
}
@@ -84,8 +78,14 @@ impl<C: Chain> StorageProofOverheadMetric<C> {
}
}
impl<C: Chain> Metric for StorageProofOverheadMetric<C> {
fn register(&self, registry: &Registry) -> Result<(), PrometheusError> {
register(self.metric.clone(), registry).map(drop)
}
}
#[async_trait]
impl<C: Chain> StandaloneMetrics for StorageProofOverheadMetric<C> {
impl<C: Chain> StandaloneMetric for StorageProofOverheadMetric<C> {
fn update_interval(&self) -> Duration {
C::AVERAGE_BLOCK_INTERVAL * UPDATE_INTERVAL_IN_BLOCKS
}