From 90cd8a8479eb42a418c2441542625e9c8b2dbce0 Mon Sep 17 00:00:00 2001 From: Gregory Terzian <2792687+gterzian@users.noreply.github.com> Date: Tue, 12 Mar 2019 17:17:29 +0800 Subject: [PATCH] Add network state to system.interval telemetry (#1959) * add network state to system.interval telemetry * use serde_json * use unwrap_or_default --- substrate/Cargo.lock | 1 + substrate/core/cli/Cargo.toml | 1 + substrate/core/cli/src/informant.rs | 3 +++ 3 files changed, 5 insertions(+) diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 473798f103..65595210a7 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -3644,6 +3644,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-client 0.1.0", diff --git a/substrate/core/cli/Cargo.toml b/substrate/core/cli/Cargo.toml index fa11796902..9ed26692c7 100644 --- a/substrate/core/cli/Cargo.toml +++ b/substrate/core/cli/Cargo.toml @@ -20,6 +20,7 @@ tokio = "0.1.7" futures = "0.1.17" fdlimit = "0.1" exit-future = "0.1" +serde_json = "1.0" sysinfo = "0.8.0" panic-handler = { package = "substrate-panic-handler", path = "../../core/panic-handler" } client = { package = "substrate-client", path = "../../core/client" } diff --git a/substrate/core/cli/src/informant.rs b/substrate/core/cli/src/informant.rs index c0ab5c3dc7..260615b2c1 100644 --- a/substrate/core/cli/src/informant.rs +++ b/substrate/core/cli/src/informant.rs @@ -82,9 +82,12 @@ pub fn start(service: &Service, exit: ::exit_future::Exit, handle: TaskExe (proc.cpu_usage(), proc.memory()) } else { (0.0, 0) }; + let network_state = serde_json::to_string(&network.network_state()).unwrap_or_default(); + telemetry!( SUBSTRATE_INFO; "system.interval"; + "network_state" => network_state, "status" => format!("{}{}", status, target), "peers" => num_peers, "height" => best_number,