Add hostname to metrics on panic
This commit is contained in:
		
				
					committed by
					
						
						sakridge
					
				
			
			
				
	
			
			
			
						parent
						
							2318ffc704
						
					
				
				
					commit
					a206f2570d
				
			@@ -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"
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -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)]
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user