feat(metrics): support arbitrary event tags and enhance monitoring coverage
Enable key-value metadata for events to track dry-run status and introduce new monitoring events for rate controller failure states.
This commit is contained in:
5 files changed
+27
-4
No files matched your search
@@ -107,6 +107,7 @@ impl Baseliner {
|
|||||||
name: "reselection",
|
name: "reselection",
|
||||||
reason: "anomaly",
|
reason: "anomaly",
|
||||||
reflector: Some(time_data.reflector),
|
reflector: Some(time_data.reflector),
|
||||||
|
tags: &[],
|
||||||
});
|
});
|
||||||
// If reselection is disabled this would trigger an error
|
// If reselection is disabled this would trigger an error
|
||||||
// so just ignore the result
|
// so just ignore the result
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
name: "starting",
|
name: "starting",
|
||||||
reason: "",
|
reason: "",
|
||||||
reflector: None,
|
reflector: None,
|
||||||
|
tags: if config.dry_run { &[("dry_run", "true")] } else { &[] },
|
||||||
});
|
});
|
||||||
|
|
||||||
let (mut ping_listener, mut ping_sender) = match config.measurement_type {
|
let (mut ping_listener, mut ping_sender) = match config.measurement_type {
|
||||||
|
|||||||
+11
-4
@@ -113,6 +113,7 @@ pub enum Metric {
|
|||||||
name: &'static str,
|
name: &'static str,
|
||||||
reason: &'static str,
|
reason: &'static str,
|
||||||
reflector: Option<IpAddr>,
|
reflector: Option<IpAddr>,
|
||||||
|
tags: &'static [(&'static str, &'static str)],
|
||||||
},
|
},
|
||||||
Dropped {
|
Dropped {
|
||||||
count: u64,
|
count: u64,
|
||||||
@@ -300,17 +301,23 @@ impl Metrics {
|
|||||||
name,
|
name,
|
||||||
reason,
|
reason,
|
||||||
reflector,
|
reflector,
|
||||||
|
tags,
|
||||||
} => {
|
} => {
|
||||||
let mut tags = format!("host={host_tag},type={name}");
|
let mut tag_str = format!("host={host_tag},type={name}");
|
||||||
|
|
||||||
if let Some(reflector) = reflector {
|
if let Some(reflector) = reflector {
|
||||||
write!(tags, ",reflector={reflector}").unwrap_or(());
|
write!(tag_str, ",reflector={reflector}").unwrap_or(());
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reason.is_empty() {
|
if !reason.is_empty() {
|
||||||
write!(tags, ",reason={reason}").unwrap_or(());
|
write!(tag_str, ",reason={reason}").unwrap_or(());
|
||||||
}
|
}
|
||||||
writeln!(out, "sqm_event,{tags} count=1i {timestamp_ns}").unwrap_or(());
|
|
||||||
|
for (k, v) in *tags {
|
||||||
|
write!(tag_str, ",{k}={v}").unwrap_or(());
|
||||||
|
}
|
||||||
|
|
||||||
|
writeln!(out, "sqm_event,{tag_str} count=1i {timestamp_ns}").unwrap_or(());
|
||||||
}
|
}
|
||||||
Metric::Dropped { count } => {
|
Metric::Dropped { count } => {
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|||||||
@@ -339,6 +339,12 @@ impl Ratecontroller {
|
|||||||
warn!(
|
warn!(
|
||||||
"One or both Netlink stats could not be read. Skipping rate control algorithm"
|
"One or both Netlink stats could not be read. Skipping rate control algorithm"
|
||||||
);
|
);
|
||||||
|
self.metrics.send(Metric::Event {
|
||||||
|
name: "netlink_read_failure",
|
||||||
|
reason: "",
|
||||||
|
reflector: None,
|
||||||
|
tags: &[],
|
||||||
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,6 +352,12 @@ impl Ratecontroller {
|
|||||||
|
|
||||||
if self.state_dl.deltas.is_empty() || self.state_ul.deltas.is_empty() {
|
if self.state_dl.deltas.is_empty() || self.state_ul.deltas.is_empty() {
|
||||||
warn!("No reflector data available, dropping to minimum rates");
|
warn!("No reflector data available, dropping to minimum rates");
|
||||||
|
self.metrics.send(Metric::Event {
|
||||||
|
name: "reflector_unavailable",
|
||||||
|
reason: "",
|
||||||
|
reflector: None,
|
||||||
|
tags: &[],
|
||||||
|
});
|
||||||
self.state_dl.next_rate = self.config.download_min_kbits;
|
self.state_dl.next_rate = self.config.download_min_kbits;
|
||||||
self.state_ul.next_rate = self.config.upload_min_kbits;
|
self.state_ul.next_rate = self.config.upload_min_kbits;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ impl ReflectorSelector {
|
|||||||
name: "reflector_selection",
|
name: "reflector_selection",
|
||||||
reason: if triggered { "triggered" } else { "timeout" },
|
reason: if triggered { "triggered" } else { "timeout" },
|
||||||
reflector: None,
|
reflector: None,
|
||||||
|
tags: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
// After 40 reselections, slow down to every 15 minutes
|
// After 40 reselections, slow down to every 15 minutes
|
||||||
@@ -131,6 +132,7 @@ impl ReflectorSelector {
|
|||||||
name: "reflector_selected",
|
name: "reflector_selected",
|
||||||
reason: "",
|
reason: "",
|
||||||
reflector: Some(peer),
|
reflector: Some(peer),
|
||||||
|
tags: &[],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user