✨ Beautify metrics datapoint logging (#5998)
This commit is contained in:
parent
4b1de02bbb
commit
3d44cffcda
|
@ -177,7 +177,6 @@ impl RepairService {
|
||||||
("repair_request", format!("{:?}", repair_request), String),
|
("repair_request", format!("{:?}", repair_request), String),
|
||||||
("to", to.to_string(), String),
|
("to", to.to_string(), String),
|
||||||
("from", local_addr.to_string(), String),
|
("from", local_addr.to_string(), String),
|
||||||
("id", id.to_string(), String)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
repair_socket.send_to(&req, to).unwrap_or_else(|e| {
|
repair_socket.send_to(&req, to).unwrap_or_else(|e| {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DataPoint {
|
pub struct DataPoint {
|
||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
|
@ -36,6 +38,15 @@ impl DataPoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for DataPoint {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "datapoint: {}", self.name)?;
|
||||||
|
for field in &self.fields {
|
||||||
|
write!(f, " {}={}", field.0, field.1)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! datapoint {
|
macro_rules! datapoint {
|
||||||
(@field $point:ident $name:expr, $string:expr, String) => {
|
(@field $point:ident $name:expr, $string:expr, String) => {
|
||||||
|
|
|
@ -206,7 +206,7 @@ impl MetricsAgent {
|
||||||
barrier.wait();
|
barrier.wait();
|
||||||
}
|
}
|
||||||
MetricsCommand::Submit(point, level) => {
|
MetricsCommand::Submit(point, level) => {
|
||||||
log!(level, "{:?}", point);
|
log!(level, "{}", point);
|
||||||
let (_, _, points) = points_map.entry(level).or_insert((
|
let (_, _, points) = points_map.entry(level).or_insert((
|
||||||
last_write_time,
|
last_write_time,
|
||||||
HashMap::new(),
|
HashMap::new(),
|
||||||
|
|
Loading…
Reference in New Issue