From 47a22c66b42546a800449e96959c4a7b858f7dd4 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 17 Jul 2018 11:00:01 -0700 Subject: [PATCH] Include program name in panic metric --- src/bin/drone.rs | 4 ++-- src/bin/fullnode.rs | 2 +- src/metrics.rs | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bin/drone.rs b/src/bin/drone.rs index 9a5a59bef2..21c140bf10 100644 --- a/src/bin/drone.rs +++ b/src/bin/drone.rs @@ -24,8 +24,8 @@ use tokio_codec::{BytesCodec, Decoder}; fn main() { env_logger::init(); - set_panic_hook(); - let matches = App::new("solana-client-demo") + set_panic_hook("drone"); + let matches = App::new("drone") .arg( Arg::with_name("leader") .short("l") diff --git a/src/bin/fullnode.rs b/src/bin/fullnode.rs index ba72042b1b..a3e8d0e4f7 100644 --- a/src/bin/fullnode.rs +++ b/src/bin/fullnode.rs @@ -18,7 +18,7 @@ use std::process::exit; fn main() -> () { env_logger::init(); - set_panic_hook(); + set_panic_hook("fullnode"); let matches = App::new("fullnode") .arg( Arg::with_name("identity") diff --git a/src/metrics.rs b/src/metrics.rs index f6ce8fc3c8..b750fd1969 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -185,7 +185,7 @@ pub fn flush() { } /// Hook the panic handler to generate a data point on each panic -pub fn set_panic_hook() { +pub fn set_panic_hook(program: &'static str) { use std::panic; use std::sync::{Once, ONCE_INIT}; static SET_HOOK: Once = ONCE_INIT; @@ -195,12 +195,16 @@ pub fn set_panic_hook() { default_hook(ono); submit( influxdb::Point::new("panic") - .add_field( + .add_tag("program", influxdb::Value::String(program.to_string())) + .add_tag( "thread", influxdb::Value::String( thread::current().name().unwrap_or("?").to_string(), ), ) + // The 'one' field exists to give Kapacitor Alerts a numerical value + // to filter on + .add_field("one", influxdb::Value::Integer(1)) .add_field( "message", influxdb::Value::String(