From b2aab98e699e8ccebd770319b10941f2c1be4302 Mon Sep 17 00:00:00 2001 From: Marcio Diaz <marcio.diaz@gmail.com> Date: Tue, 26 Nov 2019 20:06:32 +0100 Subject: [PATCH] Add graphs for each function name (#4214) --- .../client/grafana-data-source/src/lib.rs | 2 +- .../grafana-data-source/test/src/main.rs | 4 ++-- substrate/client/service/src/builder.rs | 18 +++++++++--------- substrate/client/tracing/src/lib.rs | 3 ++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/substrate/client/grafana-data-source/src/lib.rs b/substrate/client/grafana-data-source/src/lib.rs index 7373f627056..09822adb584 100644 --- a/substrate/client/grafana-data-source/src/lib.rs +++ b/substrate/client/grafana-data-source/src/lib.rs @@ -36,7 +36,7 @@ mod networking; pub use server::run_server; pub use util::now_millis; -type Metrics = HashMap<&'static str, Vec<(f32, i64)>>; +type Metrics = HashMap<String, Vec<(f32, i64)>>; lazy_static! { /// The `RwLock` wrapping the metrics. Not intended to be used directly. diff --git a/substrate/client/grafana-data-source/test/src/main.rs b/substrate/client/grafana-data-source/test/src/main.rs index bb2b317a6c4..a4769e2bbbe 100644 --- a/substrate/client/grafana-data-source/test/src/main.rs +++ b/substrate/client/grafana-data-source/test/src/main.rs @@ -26,8 +26,8 @@ async fn randomness() { let random = rand::thread_rng().gen_range(0.0, 1000.0); record_metrics!( - "random data" => random, - "random^2" => random * random + "random data".to_owned() => random, + "random^2".to_owned() => random * random ); } } diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs index 03eea9eb3f3..6d8bc53822d 100644 --- a/substrate/client/service/src/builder.rs +++ b/substrate/client/service/src/builder.rs @@ -1005,15 +1005,15 @@ ServiceBuilder< "used_state_cache_size" => used_state_cache_size, ); record_metrics!( - "peers" => num_peers, - "height" => best_number, - "txcount" => txpool_status.ready, - "cpu" => cpu_usage, - "memory" => memory, - "finalized_height" => finalized_number, - "bandwidth_download" => bandwidth_download, - "bandwidth_upload" => bandwidth_upload, - "used_state_cache_size" => used_state_cache_size + "peers".to_owned() => num_peers, + "height".to_owned() => best_number, + "txcount".to_owned() => txpool_status.ready, + "cpu".to_owned() => cpu_usage, + "memory".to_owned() => memory, + "finalized_height".to_owned() => finalized_number, + "bandwidth_download".to_owned() => bandwidth_download, + "bandwidth_upload".to_owned() => bandwidth_upload, + "used_state_cache_size".to_owned() => used_state_cache_size ); Ok(()) diff --git a/substrate/client/tracing/src/lib.rs b/substrate/client/tracing/src/lib.rs index 664d5bf7a94..d1fe48cea3d 100644 --- a/substrate/client/tracing/src/lib.rs +++ b/substrate/client/tracing/src/lib.rs @@ -202,5 +202,6 @@ fn send_telemetry(span_datum: SpanDatum) { } fn send_grafana(span_datum: SpanDatum) { - record_metrics!(span_datum.target => span_datum.overall_time.as_nanos()); + let name = format!("{}::{}", span_datum.target, span_datum.name); + record_metrics!(name => span_datum.overall_time.as_nanos()); } -- GitLab