mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 19:11:02 +00:00
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:
committed by
Bastian Köcher
parent
940d7e463b
commit
bbf8b51f9c
@@ -17,8 +17,8 @@
|
||||
use crate::{
|
||||
error::{self, Error},
|
||||
metrics::{
|
||||
metric_name, register, F64SharedRef, Gauge, PrometheusError, Registry, StandaloneMetrics,
|
||||
F64,
|
||||
metric_name, register, F64SharedRef, Gauge, Metric, PrometheusError, Registry,
|
||||
StandaloneMetric, F64,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -44,8 +44,6 @@ pub struct FloatJsonValueMetric {
|
||||
impl FloatJsonValueMetric {
|
||||
/// Create new metric instance with given name and help.
|
||||
pub fn new(
|
||||
registry: &Registry,
|
||||
prefix: Option<&str>,
|
||||
url: String,
|
||||
json_path: String,
|
||||
name: String,
|
||||
@@ -55,7 +53,7 @@ impl FloatJsonValueMetric {
|
||||
Ok(FloatJsonValueMetric {
|
||||
url,
|
||||
json_path,
|
||||
metric: register(Gauge::new(metric_name(prefix, &name), help)?, registry)?,
|
||||
metric: Gauge::new(metric_name(None, &name), help)?,
|
||||
shared_value_ref,
|
||||
})
|
||||
}
|
||||
@@ -81,8 +79,14 @@ impl FloatJsonValueMetric {
|
||||
}
|
||||
}
|
||||
|
||||
impl Metric for FloatJsonValueMetric {
|
||||
fn register(&self, registry: &Registry) -> Result<(), PrometheusError> {
|
||||
register(self.metric.clone(), registry).map(drop)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl StandaloneMetrics for FloatJsonValueMetric {
|
||||
impl StandaloneMetric for FloatJsonValueMetric {
|
||||
fn update_interval(&self) -> Duration {
|
||||
UPDATE_INTERVAL
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
//! Global system-wide Prometheus metrics exposed by relays.
|
||||
|
||||
use crate::metrics::{
|
||||
metric_name, register, Gauge, GaugeVec, Opts, PrometheusError, Registry, StandaloneMetrics,
|
||||
F64, U64,
|
||||
metric_name, register, Gauge, GaugeVec, Metric, Opts, PrometheusError, Registry,
|
||||
StandaloneMetric, F64, U64,
|
||||
};
|
||||
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
@@ -40,36 +40,36 @@ pub struct GlobalMetrics {
|
||||
|
||||
impl GlobalMetrics {
|
||||
/// Create and register global metrics.
|
||||
pub fn new(registry: &Registry, prefix: Option<&str>) -> Result<Self, PrometheusError> {
|
||||
pub fn new() -> Result<Self, PrometheusError> {
|
||||
Ok(GlobalMetrics {
|
||||
system: Arc::new(Mutex::new(System::new_with_specifics(RefreshKind::everything()))),
|
||||
system_average_load: register(
|
||||
GaugeVec::new(
|
||||
Opts::new(metric_name(prefix, "system_average_load"), "System load average"),
|
||||
&["over"],
|
||||
)?,
|
||||
registry,
|
||||
system_average_load: GaugeVec::new(
|
||||
Opts::new(metric_name(None, "system_average_load"), "System load average"),
|
||||
&["over"],
|
||||
)?,
|
||||
process_cpu_usage_percentage: register(
|
||||
Gauge::new(
|
||||
metric_name(prefix, "process_cpu_usage_percentage"),
|
||||
"Process CPU usage",
|
||||
)?,
|
||||
registry,
|
||||
process_cpu_usage_percentage: Gauge::new(
|
||||
metric_name(None, "process_cpu_usage_percentage"),
|
||||
"Process CPU usage",
|
||||
)?,
|
||||
process_memory_usage_bytes: register(
|
||||
Gauge::new(
|
||||
metric_name(prefix, "process_memory_usage_bytes"),
|
||||
"Process memory (resident set size) usage",
|
||||
)?,
|
||||
registry,
|
||||
process_memory_usage_bytes: Gauge::new(
|
||||
metric_name(None, "process_memory_usage_bytes"),
|
||||
"Process memory (resident set size) usage",
|
||||
)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Metric for GlobalMetrics {
|
||||
fn register(&self, registry: &Registry) -> Result<(), PrometheusError> {
|
||||
register(self.system_average_load.clone(), registry)?;
|
||||
register(self.process_cpu_usage_percentage.clone(), registry)?;
|
||||
register(self.process_memory_usage_bytes.clone(), registry)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl StandaloneMetrics for GlobalMetrics {
|
||||
impl StandaloneMetric for GlobalMetrics {
|
||||
async fn update(&self) {
|
||||
// update system-wide metrics
|
||||
let mut system = self.system.lock().await;
|
||||
|
||||
Reference in New Issue
Block a user