Include program name in panic metric

This commit is contained in:
Michael Vines 2018-07-17 11:00:01 -07:00
parent fb11d8a909
commit 47a22c66b4
3 changed files with 9 additions and 5 deletions

View File

@ -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")

View File

@ -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")

View File

@ -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(