improvements
This commit is contained in:
+35
-44
@@ -9,6 +9,7 @@ use tokio::select;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::SourceMetricSet;
|
||||
use crate::{
|
||||
ChimemonSource, ChimemonSourceChannel, MetricTags, SourceMetric, SourceReport,
|
||||
SourceReportDetails, SourceStatus, config::ChronyConfig,
|
||||
@@ -43,26 +44,24 @@ impl SourceReportDetails for ChronyTrackingReport {
|
||||
fn is_healthy(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn to_metrics(&self) -> Vec<SourceMetric> {
|
||||
let tags = &self.tags;
|
||||
vec![
|
||||
SourceMetric::new_int("ref_id", self.ref_id, tags.clone()),
|
||||
SourceMetric::new_int("stratum", self.stratum, tags.clone()),
|
||||
SourceMetric::new_int("leap_status", self.leap_status, tags.clone()),
|
||||
SourceMetric::new_float("current_correction", self.current_correction, tags.clone()),
|
||||
SourceMetric::new_float("last_offset", self.last_offset, tags.clone()),
|
||||
SourceMetric::new_float("rms_offset", self.rms_offset, tags.clone()),
|
||||
SourceMetric::new_float("freq_ppm", self.freq_ppm, tags.clone()),
|
||||
SourceMetric::new_float("resid_freq_ppm", self.resid_freq_ppm, tags.clone()),
|
||||
SourceMetric::new_float("skew_ppm", self.skew_ppm, tags.clone()),
|
||||
SourceMetric::new_float("root_delay", self.root_delay, tags.clone()),
|
||||
SourceMetric::new_float("root_dispersion", self.root_dispersion, tags.clone()),
|
||||
SourceMetric::new_float(
|
||||
"last_update_interval",
|
||||
self.last_update_interval,
|
||||
tags.clone(),
|
||||
),
|
||||
]
|
||||
fn to_metrics(&self) -> Vec<SourceMetricSet> {
|
||||
vec![SourceMetricSet {
|
||||
tags: self.tags.clone(),
|
||||
metrics: vec![
|
||||
SourceMetric::new_int("ref_id", self.ref_id),
|
||||
SourceMetric::new_int("stratum", self.stratum),
|
||||
SourceMetric::new_int("leap_status", self.leap_status),
|
||||
SourceMetric::new_float("current_correction", self.current_correction),
|
||||
SourceMetric::new_float("last_offset", self.last_offset),
|
||||
SourceMetric::new_float("rms_offset", self.rms_offset),
|
||||
SourceMetric::new_float("freq_ppm", self.freq_ppm),
|
||||
SourceMetric::new_float("resid_freq_ppm", self.resid_freq_ppm),
|
||||
SourceMetric::new_float("skew_ppm", self.skew_ppm),
|
||||
SourceMetric::new_float("root_delay", self.root_delay),
|
||||
SourceMetric::new_float("root_dispersion", self.root_dispersion),
|
||||
SourceMetric::new_float("last_update_interval", self.last_update_interval),
|
||||
],
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +75,8 @@ impl SourceReportDetails for ChronySourcesReport {
|
||||
//TODO: think about whether there is an idea of unhealthy sources
|
||||
true
|
||||
}
|
||||
fn to_metrics(&self) -> Vec<SourceMetric> {
|
||||
let mut metrics = Vec::with_capacity(8 * self.sources.len());
|
||||
fn to_metrics(&self) -> Vec<SourceMetricSet> {
|
||||
let mut metrics = Vec::with_capacity(self.sources.len());
|
||||
|
||||
for source in &self.sources {
|
||||
let tags = Arc::new(vec![
|
||||
@@ -102,28 +101,19 @@ impl SourceReportDetails for ChronySourcesReport {
|
||||
},
|
||||
),
|
||||
]);
|
||||
metrics.extend([
|
||||
SourceMetric::new_int("poll", source.poll as i64, tags.clone()),
|
||||
SourceMetric::new_int("stratum", source.stratum as i64, tags.clone()),
|
||||
SourceMetric::new_int("flags", source.flags.bits() as i64, tags.clone()),
|
||||
SourceMetric::new_int(
|
||||
"reachability",
|
||||
source.reachability.count_ones() as i64,
|
||||
tags.clone(),
|
||||
),
|
||||
SourceMetric::new_int("since_sample", source.since_sample as i64, tags.clone()),
|
||||
SourceMetric::new_float(
|
||||
"orig_latest_meas",
|
||||
source.orig_latest_meas.into(),
|
||||
tags.clone(),
|
||||
),
|
||||
SourceMetric::new_float("latest_meas", source.latest_meas.into(), tags.clone()),
|
||||
SourceMetric::new_float(
|
||||
"latest_meas_err",
|
||||
source.latest_meas_err.into(),
|
||||
tags.clone(),
|
||||
),
|
||||
]);
|
||||
metrics.push(SourceMetricSet {
|
||||
tags: tags,
|
||||
metrics: vec![
|
||||
SourceMetric::new_int("poll", source.poll as i64),
|
||||
SourceMetric::new_int("stratum", source.stratum as i64),
|
||||
SourceMetric::new_int("flags", source.flags.bits() as i64),
|
||||
SourceMetric::new_int("reachability", source.reachability.count_ones() as i64),
|
||||
SourceMetric::new_int("since_sample", source.since_sample as i64),
|
||||
SourceMetric::new_float("orig_latest_meas", source.orig_latest_meas.into()),
|
||||
SourceMetric::new_float("latest_meas", source.latest_meas.into()),
|
||||
SourceMetric::new_float("latest_meas_err", source.latest_meas_err.into()),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
metrics
|
||||
@@ -280,6 +270,7 @@ impl ChronyClient {
|
||||
#[async_trait]
|
||||
impl ChimemonSource for ChronyClient {
|
||||
type Config = ChronyConfig;
|
||||
const TASK_NAME: &'static str = "chrony-task";
|
||||
fn new(name: &str, config: Self::Config) -> Self {
|
||||
let server = config
|
||||
.host
|
||||
|
||||
Reference in New Issue
Block a user