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:
Benjamin Kampmann
2020-04-04 15:13:35 +02:00
committed by GitHub
parent 6847f8452e
commit 247822bb33
60 changed files with 1344 additions and 526 deletions
+6 -5
View File
@@ -20,11 +20,12 @@
mod peersstate;
use std::{collections::{HashSet, HashMap}, collections::VecDeque};
use futures::{prelude::*, channel::mpsc};
use futures::prelude::*;
use log::{debug, error, trace};
use serde_json::json;
use std::{pin::Pin, task::{Context, Poll}, time::Duration};
use wasm_timer::Instant;
use sp_utils::mpsc::{tracing_unbounded, TracingUnboundedSender, TracingUnboundedReceiver};
pub use libp2p::PeerId;
@@ -73,7 +74,7 @@ impl ReputationChange {
/// Shared handle to the peer set manager (PSM). Distributed around the code.
#[derive(Debug, Clone)]
pub struct PeersetHandle {
tx: mpsc::UnboundedSender<Action>,
tx: TracingUnboundedSender<Action>,
}
impl PeersetHandle {
@@ -183,9 +184,9 @@ pub struct Peerset {
/// If true, we only accept reserved nodes.
reserved_only: bool,
/// Receiver for messages from the `PeersetHandle` and from `tx`.
rx: mpsc::UnboundedReceiver<Action>,
rx: TracingUnboundedReceiver<Action>,
/// Sending side of `rx`.
tx: mpsc::UnboundedSender<Action>,
tx: TracingUnboundedSender<Action>,
/// Queue of messages to be emitted when the `Peerset` is polled.
message_queue: VecDeque<Message>,
/// When the `Peerset` was created.
@@ -197,7 +198,7 @@ pub struct Peerset {
impl Peerset {
/// Builds a new peerset from the given configuration.
pub fn from_config(config: PeersetConfig) -> (Peerset, PeersetHandle) {
let (tx, rx) = mpsc::unbounded();
let (tx, rx) = tracing_unbounded("mpsc_peerset_messages");
let handle = PeersetHandle {
tx: tx.clone(),