mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 03:21:02 +00:00
Additional Metrics collected and exposed via prometheus (#5414)
This PR refactors the metrics measuring and Prometheus exposing entity in sc-service into its own submodule and extends the parameters it exposes by: - system load average (over one, five and 15min) - the TCP connection state of the process (lsof), refs #5304 - number of tokio threads - number of known forks - counter for items in each unbounded queue (with internal unbounded channels) - number of file descriptors opened by this process (*nix only at this point) - number of system threads (*nix only at this point) refs #4679 Co-authored-by: Max Inden <mail@max-inden.de> Co-authored-by: Ashley <ashley.ruglys@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6847f8452e
commit
247822bb33
@@ -90,7 +90,7 @@ use sp_finality_grandpa::AuthorityId;
|
||||
|
||||
use sc_telemetry::{telemetry, CONSENSUS_DEBUG};
|
||||
use log::{trace, debug};
|
||||
use futures::channel::mpsc;
|
||||
use sp_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use prometheus_endpoint::{CounterVec, Opts, PrometheusError, register, Registry, U64};
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
@@ -1254,7 +1254,7 @@ impl Metrics {
|
||||
pub(super) struct GossipValidator<Block: BlockT> {
|
||||
inner: parking_lot::RwLock<Inner<Block>>,
|
||||
set_state: environment::SharedVoterSetState<Block>,
|
||||
report_sender: mpsc::UnboundedSender<PeerReport>,
|
||||
report_sender: TracingUnboundedSender<PeerReport>,
|
||||
metrics: Option<Metrics>,
|
||||
}
|
||||
|
||||
@@ -1266,7 +1266,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
||||
config: crate::Config,
|
||||
set_state: environment::SharedVoterSetState<Block>,
|
||||
prometheus_registry: Option<&Registry>,
|
||||
) -> (GossipValidator<Block>, mpsc::UnboundedReceiver<PeerReport>) {
|
||||
) -> (GossipValidator<Block>, TracingUnboundedReceiver<PeerReport>) {
|
||||
let metrics = match prometheus_registry.map(Metrics::register) {
|
||||
Some(Ok(metrics)) => Some(metrics),
|
||||
Some(Err(e)) => {
|
||||
@@ -1276,7 +1276,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
||||
None => None,
|
||||
};
|
||||
|
||||
let (tx, rx) = mpsc::unbounded();
|
||||
let (tx, rx) = tracing_unbounded("mpsc_grandpa_gossip_validator");
|
||||
let val = GossipValidator {
|
||||
inner: parking_lot::RwLock::new(Inner::new(config)),
|
||||
set_state,
|
||||
|
||||
@@ -58,6 +58,7 @@ use gossip::{
|
||||
use sp_finality_grandpa::{
|
||||
AuthorityPair, AuthorityId, AuthoritySignature, SetId as SetIdNumber, RoundNumber,
|
||||
};
|
||||
use sp_utils::mpsc::TracingUnboundedReceiver;
|
||||
|
||||
pub mod gossip;
|
||||
mod periodic;
|
||||
@@ -165,7 +166,7 @@ pub(crate) struct NetworkBridge<B: BlockT, N: Network<B>> {
|
||||
// thus one has to wrap gossip_validator_report_stream with an `Arc` `Mutex`. Given that it is
|
||||
// just an `UnboundedReceiver`, one could also switch to a multi-producer-*multi*-consumer
|
||||
// channel implementation.
|
||||
gossip_validator_report_stream: Arc<Mutex<mpsc::UnboundedReceiver<PeerReport>>>,
|
||||
gossip_validator_report_stream: Arc<Mutex<TracingUnboundedReceiver<PeerReport>>>,
|
||||
}
|
||||
|
||||
impl<B: BlockT, N: Network<B>> Unpin for NetworkBridge<B, N> {}
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
//! Periodic rebroadcast of neighbor packets.
|
||||
|
||||
use futures_timer::Delay;
|
||||
use futures::{channel::mpsc, future::{FutureExt as _}, prelude::*, ready, stream::Stream};
|
||||
use futures::{future::{FutureExt as _}, prelude::*, ready, stream::Stream};
|
||||
use log::debug;
|
||||
use std::{pin::Pin, task::{Context, Poll}, time::Duration};
|
||||
use sp_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
|
||||
use sc_network::PeerId;
|
||||
use sp_runtime::traits::{NumberFor, Block as BlockT};
|
||||
@@ -31,7 +32,7 @@ const REBROADCAST_AFTER: Duration = Duration::from_secs(2 * 60);
|
||||
/// A sender used to send neighbor packets to a background job.
|
||||
#[derive(Clone)]
|
||||
pub(super) struct NeighborPacketSender<B: BlockT>(
|
||||
mpsc::UnboundedSender<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>
|
||||
TracingUnboundedSender<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>
|
||||
);
|
||||
|
||||
impl<B: BlockT> NeighborPacketSender<B> {
|
||||
@@ -54,14 +55,15 @@ impl<B: BlockT> NeighborPacketSender<B> {
|
||||
pub(super) struct NeighborPacketWorker<B: BlockT> {
|
||||
last: Option<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>,
|
||||
delay: Delay,
|
||||
rx: mpsc::UnboundedReceiver<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>,
|
||||
rx: TracingUnboundedReceiver<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>,
|
||||
}
|
||||
|
||||
impl<B: BlockT> Unpin for NeighborPacketWorker<B> {}
|
||||
|
||||
impl<B: BlockT> NeighborPacketWorker<B> {
|
||||
pub(super) fn new() -> (Self, NeighborPacketSender<B>){
|
||||
let (tx, rx) = mpsc::unbounded::<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>();
|
||||
let (tx, rx) = tracing_unbounded::<(Vec<PeerId>, NeighborPacket<NumberFor<B>>)>
|
||||
("mpsc_grandpa_neighbor_packet_worker");
|
||||
let delay = Delay::new(REBROADCAST_AFTER);
|
||||
|
||||
(NeighborPacketWorker {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Tests for the communication portion of the GRANDPA crate.
|
||||
|
||||
use futures::channel::mpsc;
|
||||
use sp_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use futures::prelude::*;
|
||||
use sc_network::{Event as NetworkEvent, ObservedRole, PeerId};
|
||||
use sc_network_test::{Block, Hash};
|
||||
@@ -33,7 +33,7 @@ use super::{AuthorityId, VoterSet, Round, SetId};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum Event {
|
||||
EventStream(mpsc::UnboundedSender<NetworkEvent>),
|
||||
EventStream(TracingUnboundedSender<NetworkEvent>),
|
||||
WriteNotification(sc_network::PeerId, Vec<u8>),
|
||||
Report(sc_network::PeerId, sc_network::ReputationChange),
|
||||
Announce(Hash),
|
||||
@@ -41,12 +41,12 @@ pub(crate) enum Event {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct TestNetwork {
|
||||
sender: mpsc::UnboundedSender<Event>,
|
||||
sender: TracingUnboundedSender<Event>,
|
||||
}
|
||||
|
||||
impl sc_network_gossip::Network<Block> for TestNetwork {
|
||||
fn event_stream(&self) -> Pin<Box<dyn Stream<Item = NetworkEvent> + Send>> {
|
||||
let (tx, rx) = mpsc::unbounded();
|
||||
let (tx, rx) = tracing_unbounded("test");
|
||||
let _ = self.sender.unbounded_send(Event::EventStream(tx));
|
||||
Box::pin(rx)
|
||||
}
|
||||
@@ -97,7 +97,7 @@ impl sc_network_gossip::ValidatorContext<Block> for TestNetwork {
|
||||
pub(crate) struct Tester {
|
||||
pub(crate) net_handle: super::NetworkBridge<Block, TestNetwork>,
|
||||
gossip_validator: Arc<GossipValidator<Block>>,
|
||||
pub(crate) events: mpsc::UnboundedReceiver<Event>,
|
||||
pub(crate) events: TracingUnboundedReceiver<Event>,
|
||||
}
|
||||
|
||||
impl Tester {
|
||||
@@ -161,7 +161,7 @@ pub(crate) fn make_test_network() -> (
|
||||
impl Future<Output = Tester>,
|
||||
TestNetwork,
|
||||
) {
|
||||
let (tx, rx) = mpsc::unbounded();
|
||||
let (tx, rx) = tracing_unbounded("test");
|
||||
let net = TestNetwork { sender: tx };
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
Reference in New Issue
Block a user