From 324e51fbbf842ab1561ef882ef7c21eb47bebd53 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 24 Apr 2020 17:40:48 +0200 Subject: [PATCH] client/authority-discovery: Reduce log level replaced by metrics Instead of logging value-found-event-handling failures or value-put failures on error level, log them on debug level only additionally recording them via Prometheus. Motivation is that both events can happen in "normal" operations and thus clutter the logs. --- .../client/authority-discovery/src/lib.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/substrate/client/authority-discovery/src/lib.rs b/substrate/client/authority-discovery/src/lib.rs index 91e8293dec..e5b7c986a4 100644 --- a/substrate/client/authority-discovery/src/lib.rs +++ b/substrate/client/authority-discovery/src/lib.rs @@ -60,7 +60,7 @@ use futures_timer::Delay; use codec::{Decode, Encode}; use error::{Error, Result}; -use log::{debug, error, log_enabled, warn}; +use log::{debug, error, log_enabled}; use prometheus_endpoint::{Counter, CounterVec, Gauge, Opts, U64, register}; use prost::Message; use sc_client_api::blockchain::HeaderBackend; @@ -328,7 +328,11 @@ where } if let Err(e) = self.handle_dht_value_found_event(v) { - error!( + if let Some(metrics) = &self.metrics { + metrics.handle_value_found_event_failure.inc(); + } + + debug!( target: LOG_TARGET, "Failed to handle Dht value found event: {:?}", e, ); @@ -359,7 +363,7 @@ where metrics.dht_event_received.with_label_values(&["value_put_failed"]).inc(); } - warn!( + debug!( target: LOG_TARGET, "Failed to put hash '{:?}' on Dht.", hash ) @@ -603,6 +607,7 @@ pub(crate) struct Metrics { amount_last_published: Gauge, request: Counter, dht_event_received: CounterVec, + handle_value_found_event_failure: Counter, priority_group_size: Gauge, } @@ -642,6 +647,13 @@ impl Metrics { )?, registry, )?, + handle_value_found_event_failure: register( + Counter::new( + "authority_discovery_handle_value_found_event_failure", + "Number of times handling a dht value found event failed." + )?, + registry, + )?, priority_group_size: register( Gauge::new( "authority_discovery_priority_group_size",