Add hostname to metrics on panic

This commit is contained in:
Stephen Akridge
2018-08-10 15:59:41 -07:00
committed by sakridge
parent 2318ffc704
commit a206f2570d
4 changed files with 9 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
use std::sync::{Arc, Barrier, Mutex, Once, ONCE_INIT};
use std::thread;
use std::time::{Duration, Instant};
use sys_info::hostname;
use timing;
#[derive(Debug)]
@@ -219,6 +220,12 @@ pub fn set_panic_hook(program: &'static str) {
None => "?".to_string(),
}),
)
.add_field(
"host",
influxdb::Value::String(
hostname().unwrap_or_else(|_| "?".to_string())
),
)
.to_owned(),
);
// Flush metrics immediately in case the process exits immediately