Include program name in panic metric
This commit is contained in:
parent
fb11d8a909
commit
47a22c66b4
|
@ -24,8 +24,8 @@ use tokio_codec::{BytesCodec, Decoder};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
set_panic_hook();
|
set_panic_hook("drone");
|
||||||
let matches = App::new("solana-client-demo")
|
let matches = App::new("drone")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("leader")
|
Arg::with_name("leader")
|
||||||
.short("l")
|
.short("l")
|
||||||
|
|
|
@ -18,7 +18,7 @@ use std::process::exit;
|
||||||
|
|
||||||
fn main() -> () {
|
fn main() -> () {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
set_panic_hook();
|
set_panic_hook("fullnode");
|
||||||
let matches = App::new("fullnode")
|
let matches = App::new("fullnode")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("identity")
|
Arg::with_name("identity")
|
||||||
|
|
|
@ -185,7 +185,7 @@ pub fn flush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hook the panic handler to generate a data point on each panic
|
/// 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::panic;
|
||||||
use std::sync::{Once, ONCE_INIT};
|
use std::sync::{Once, ONCE_INIT};
|
||||||
static SET_HOOK: Once = ONCE_INIT;
|
static SET_HOOK: Once = ONCE_INIT;
|
||||||
|
@ -195,12 +195,16 @@ pub fn set_panic_hook() {
|
||||||
default_hook(ono);
|
default_hook(ono);
|
||||||
submit(
|
submit(
|
||||||
influxdb::Point::new("panic")
|
influxdb::Point::new("panic")
|
||||||
.add_field(
|
.add_tag("program", influxdb::Value::String(program.to_string()))
|
||||||
|
.add_tag(
|
||||||
"thread",
|
"thread",
|
||||||
influxdb::Value::String(
|
influxdb::Value::String(
|
||||||
thread::current().name().unwrap_or("?").to_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(
|
.add_field(
|
||||||
"message",
|
"message",
|
||||||
influxdb::Value::String(
|
influxdb::Value::String(
|
||||||
|
|
Loading…
Reference in New Issue