diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 06f117b3bb66f..936985136b7b4 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -48,7 +48,7 @@ use sp_runtime::traits::{ use sp_arithmetic::traits::SaturatedConversion; use message::{BlockAnnounce, Message}; use message::generic::{Message as GenericMessage, ConsensusMessage, Roles}; -use prometheus_endpoint::{Registry, Gauge, GaugeVec, HistogramVec, PrometheusError, Opts, register, U64}; +use prometheus_endpoint::{Registry, Gauge, Counter, GaugeVec, HistogramVec, PrometheusError, Opts, register, U64}; use sync::{ChainSync, SyncState}; use std::borrow::Cow; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; @@ -145,6 +145,7 @@ struct Metrics { fork_targets: Gauge, finality_proofs: GaugeVec, justifications: GaugeVec, + propagated_extrinsics: Counter, } impl Metrics { @@ -190,6 +191,10 @@ impl Metrics { )?; register(g, r)? }, + propagated_extrinsics: register(Counter::new( + "sync_propagated_extrinsics", + "Number of transactions propagated to at least one peer", + )?, r)?, }) } } @@ -1232,6 +1237,12 @@ impl Protocol { } } + if propagated_to.len() > 0 { + if let Some(ref metrics) = self.metrics { + metrics.propagated_extrinsics.inc(); + } + } + propagated_to }