Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit c8c16d1

Browse files
authored
add network propagated metrics (#6438)
1 parent 4c67aee commit c8c16d1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

client/network/src/protocol.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use sp_runtime::traits::{
4848
use sp_arithmetic::traits::SaturatedConversion;
4949
use message::{BlockAnnounce, Message};
5050
use message::generic::{Message as GenericMessage, ConsensusMessage, Roles};
51-
use prometheus_endpoint::{Registry, Gauge, GaugeVec, HistogramVec, PrometheusError, Opts, register, U64};
51+
use prometheus_endpoint::{Registry, Gauge, Counter, GaugeVec, HistogramVec, PrometheusError, Opts, register, U64};
5252
use sync::{ChainSync, SyncState};
5353
use std::borrow::Cow;
5454
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
@@ -145,6 +145,7 @@ struct Metrics {
145145
fork_targets: Gauge<U64>,
146146
finality_proofs: GaugeVec<U64>,
147147
justifications: GaugeVec<U64>,
148+
propagated_extrinsics: Counter<U64>,
148149
}
149150

150151
impl Metrics {
@@ -190,6 +191,10 @@ impl Metrics {
190191
)?;
191192
register(g, r)?
192193
},
194+
propagated_extrinsics: register(Counter::new(
195+
"sync_propagated_extrinsics",
196+
"Number of transactions propagated to at least one peer",
197+
)?, r)?,
193198
})
194199
}
195200
}
@@ -1237,6 +1242,12 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
12371242
}
12381243
}
12391244

1245+
if propagated_to.len() > 0 {
1246+
if let Some(ref metrics) = self.metrics {
1247+
metrics.propagated_extrinsics.inc();
1248+
}
1249+
}
1250+
12401251
propagated_to
12411252
}
12421253

0 commit comments

Comments
 (0)