Beautify metrics datapoint logging (#5998)

This commit is contained in:
Michael Vines 2019-09-20 12:00:43 -07:00 committed by GitHub
parent 4b1de02bbb
commit 3d44cffcda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -177,7 +177,6 @@ impl RepairService {
("repair_request", format!("{:?}", repair_request), String),
("to", to.to_string(), String),
("from", local_addr.to_string(), String),
("id", id.to_string(), String)
);
}
repair_socket.send_to(&req, to).unwrap_or_else(|e| {

View File

@ -1,3 +1,5 @@
use std::fmt;
#[derive(Clone, Debug)]
pub struct DataPoint {
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_rules! datapoint {
(@field $point:ident $name:expr, $string:expr, String) => {

View File

@ -206,7 +206,7 @@ impl MetricsAgent {
barrier.wait();
}
MetricsCommand::Submit(point, level) => {
log!(level, "{:?}", point);
log!(level, "{}", point);
let (_, _, points) = points_map.entry(level).or_insert((
last_write_time,
HashMap::new(),