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

Commit

Permalink
add network propagated metrics (#6438)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf authored Jun 19, 2020
1 parent 4c67aee commit c8c16d1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -145,6 +145,7 @@ struct Metrics {
fork_targets: Gauge<U64>,
finality_proofs: GaugeVec<U64>,
justifications: GaugeVec<U64>,
propagated_extrinsics: Counter<U64>,
}

impl Metrics {
Expand Down Expand Up @@ -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)?,
})
}
}
Expand Down Expand Up @@ -1237,6 +1242,12 @@ impl<B: BlockT, H: ExHashT> Protocol<B, H> {
}
}

if propagated_to.len() > 0 {
if let Some(ref metrics) = self.metrics {
metrics.propagated_extrinsics.inc();
}
}

propagated_to
}

Expand Down

0 comments on commit c8c16d1

Please sign in to comment.