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",
|
||||
reason: "anomaly",
|
||||
reflector: Some(time_data.reflector),
|
||||
tags: &[],
|
||||
});
|
||||
// If reselection is disabled this would trigger an error
|
||||
// so just ignore the result
|
||||
|
||||
@@ -123,6 +123,7 @@ fn main() -> anyhow::Result<()> {
|
||||
name: "starting",
|
||||
reason: "",
|
||||
reflector: None,
|
||||
tags: if config.dry_run { &[("dry_run", "true")] } else { &[] },
|
||||
});
|
||||
|
||||
let (mut ping_listener, mut ping_sender) = match config.measurement_type {
|
||||
|
||||
+11
-4
@@ -113,6 +113,7 @@ pub enum Metric {
|
||||
name: &'static str,
|
||||
reason: &'static str,
|
||||
reflector: Option<IpAddr>,
|
||||
tags: &'static [(&'static str, &'static str)],
|
||||
},
|
||||
Dropped {
|
||||
count: u64,
|
||||
@@ -300,17 +301,23 @@ impl Metrics {
|
||||
name,
|
||||
reason,
|
||||
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 {
|
||||
write!(tags, ",reflector={reflector}").unwrap_or(());
|
||||
write!(tag_str, ",reflector={reflector}").unwrap_or(());
|
||||
}
|
||||
|
||||
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 } => {
|
||||
writeln!(
|
||||
|
||||
@@ -339,6 +339,12 @@ impl Ratecontroller {
|
||||
warn!(
|
||||
"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;
|
||||
}
|
||||
|
||||
@@ -346,6 +352,12 @@ impl Ratecontroller {
|
||||
|
||||
if self.state_dl.deltas.is_empty() || self.state_ul.deltas.is_empty() {
|
||||
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_ul.next_rate = self.config.upload_min_kbits;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ impl ReflectorSelector {
|
||||
name: "reflector_selection",
|
||||
reason: if triggered { "triggered" } else { "timeout" },
|
||||
reflector: None,
|
||||
tags: &[],
|
||||
});
|
||||
|
||||
// After 40 reselections, slow down to every 15 minutes
|
||||
@@ -131,6 +132,7 @@ impl ReflectorSelector {
|
||||
name: "reflector_selected",
|
||||
reason: "",
|
||||
reflector: Some(peer),
|
||||
tags: &[],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user