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

@ -89,6 +89,7 @@ sha2 = "0.7.0"
serde = "1.0.27"
serde_derive = "1.0.27"
serde_json = "1.0.10"
sys-info = "0.5.6"
tokio = "0.1"
tokio-codec = "0.1"
tokio-core = "0.1.17"

View File

@ -18,7 +18,6 @@ use solana::wallet::request_airdrop;
use std::fs::File;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::process::exit;
//use std::time::Duration;
fn main() -> () {
logger::setup();

View File

@ -72,6 +72,7 @@ extern crate serde_derive;
extern crate pnet_datalink;
extern crate serde_json;
extern crate sha2;
extern crate sys_info;
extern crate untrusted;
#[cfg(test)]

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