mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-12 21:31:01 +00:00
I/O metrics (#224)
* feat: Proxy Node IO stats to the FE * chore: Sync up FE * feat: Charts for cache sizes * feat: All graphs are in * chore: Remove browserlist
This commit is contained in:
@@ -213,7 +213,7 @@ impl Handler<Connect> for Aggregator {
|
||||
|
||||
connector.do_send(Connected(fid));
|
||||
|
||||
self.serializer.push(feed::Version(28));
|
||||
self.serializer.push(feed::Version(29));
|
||||
|
||||
// TODO: keep track on number of nodes connected to each chain
|
||||
for (_, entry) in self.chains.iter() {
|
||||
|
||||
@@ -273,6 +273,10 @@ impl Handler<UpdateNode> for Chain {
|
||||
if let Some(stats) = node.update_stats(interval) {
|
||||
self.serializer.push(feed::NodeStatsUpdate(nid, stats));
|
||||
}
|
||||
|
||||
if let Some(io) = node.update_io(interval) {
|
||||
self.serializer.push(feed::NodeIOUpdate(nid, io));
|
||||
}
|
||||
}
|
||||
Details::SystemNetworkState(_) => {
|
||||
if let Some(raw) = raw {
|
||||
|
||||
+7
-2
@@ -4,7 +4,7 @@ use serde::ser::{Serializer, SerializeTuple};
|
||||
use serde_json::to_writer;
|
||||
use crate::node::Node;
|
||||
use crate::types::{
|
||||
NodeId, NodeStats, NodeHardware, BlockNumber, BlockHash, BlockDetails, Timestamp, Address,
|
||||
NodeId, NodeStats, NodeHardware, NodeIO, BlockNumber, BlockHash, BlockDetails, Timestamp, Address,
|
||||
};
|
||||
|
||||
pub mod connector;
|
||||
@@ -91,6 +91,7 @@ actions! {
|
||||
0x12: AfgReceivedPrecommit,
|
||||
0x13: AfgAuthoritySet,
|
||||
0x14: StaleNode,
|
||||
0x15: NodeIOUpdate<'_>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -119,6 +120,9 @@ pub struct FinalizedBlock(pub NodeId, pub BlockNumber, pub BlockHash);
|
||||
#[derive(Serialize)]
|
||||
pub struct NodeStatsUpdate<'a>(pub NodeId, pub &'a NodeStats);
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct NodeIOUpdate<'a>(pub NodeId, pub &'a NodeIO);
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Hardware<'a>(pub NodeId, pub &'a NodeHardware);
|
||||
|
||||
@@ -161,10 +165,11 @@ impl Serialize for AddedNode<'_> {
|
||||
S: Serializer,
|
||||
{
|
||||
let AddedNode(nid, node) = self;
|
||||
let mut tup = serializer.serialize_tuple(7)?;
|
||||
let mut tup = serializer.serialize_tuple(8)?;
|
||||
tup.serialize_element(nid)?;
|
||||
tup.serialize_element(node.details())?;
|
||||
tup.serialize_element(node.stats())?;
|
||||
tup.serialize_element(node.io())?;
|
||||
tup.serialize_element(node.hardware())?;
|
||||
tup.serialize_element(node.block_details())?;
|
||||
tup.serialize_element(&node.location())?;
|
||||
|
||||
+34
-12
@@ -1,7 +1,7 @@
|
||||
use bytes::Bytes;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::types::{NodeId, NodeDetails, NodeStats, NodeHardware, NodeLocation, BlockDetails, Block, Timestamp};
|
||||
use crate::types::{NodeId, NodeDetails, NodeStats, NodeIO, NodeHardware, NodeLocation, BlockDetails, Block, Timestamp};
|
||||
use crate::util::now;
|
||||
|
||||
pub mod message;
|
||||
@@ -19,6 +19,8 @@ pub struct Node {
|
||||
details: NodeDetails,
|
||||
/// Basic stats
|
||||
stats: NodeStats,
|
||||
/// Node IO stats
|
||||
io: NodeIO,
|
||||
/// Best block
|
||||
best: BlockDetails,
|
||||
/// Finalized block
|
||||
@@ -42,16 +44,9 @@ impl Node {
|
||||
Node {
|
||||
|
||||
details,
|
||||
stats: NodeStats {
|
||||
txcount: 0,
|
||||
peers: 0,
|
||||
},
|
||||
best: BlockDetails {
|
||||
block: Block::zero(),
|
||||
block_timestamp: now(),
|
||||
block_time: 0,
|
||||
propagation_time: None,
|
||||
},
|
||||
stats: NodeStats::default(),
|
||||
io: NodeIO::default(),
|
||||
best: BlockDetails::default(),
|
||||
finalized: Block::zero(),
|
||||
throttle: 0,
|
||||
hardware: NodeHardware::default(),
|
||||
@@ -70,6 +65,10 @@ impl Node {
|
||||
&self.stats
|
||||
}
|
||||
|
||||
pub fn io(&self) -> &NodeIO {
|
||||
&self.io
|
||||
}
|
||||
|
||||
pub fn best(&self) -> &Block {
|
||||
&self.best.block
|
||||
}
|
||||
@@ -105,7 +104,7 @@ impl Node {
|
||||
if block.height > self.best.block.height {
|
||||
self.stale = false;
|
||||
self.best.block = block;
|
||||
|
||||
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@@ -157,6 +156,29 @@ impl Node {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_io(&mut self, interval: &SystemInterval) -> Option<&NodeIO> {
|
||||
let mut changed = false;
|
||||
|
||||
if let Some(size) = interval.used_state_cache_size {
|
||||
changed |= self.io.used_state_cache_size.push(size);
|
||||
}
|
||||
if let Some(size) = interval.used_db_cache_size {
|
||||
changed |= self.io.used_db_cache_size.push(size);
|
||||
}
|
||||
if let Some(bps) = interval.disk_read_per_sec {
|
||||
changed |= self.io.disk_read_per_sec.push(bps);
|
||||
}
|
||||
if let Some(bps) = interval.disk_write_per_sec {
|
||||
changed |= self.io.disk_write_per_sec.push(bps);
|
||||
}
|
||||
|
||||
if changed {
|
||||
Some(&self.io)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_finalized(&mut self, block: Block) -> Option<&Block> {
|
||||
if block.height > self.finalized.height {
|
||||
self.finalized = block;
|
||||
|
||||
@@ -74,6 +74,10 @@ pub struct SystemInterval {
|
||||
#[serde(flatten)]
|
||||
pub block: Block,
|
||||
pub network_state: Option<IgnoredAny>,
|
||||
pub used_state_cache_size: Option<f32>,
|
||||
pub used_db_cache_size: Option<f32>,
|
||||
pub disk_read_per_sec: Option<f32>,
|
||||
pub disk_write_per_sec: Option<f32>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
||||
+35
-2
@@ -1,7 +1,7 @@
|
||||
use serde::ser::{Serialize, Serializer, SerializeTuple};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::util::MeanList;
|
||||
use crate::util::{MeanList, now};
|
||||
|
||||
pub type NodeId = usize;
|
||||
pub type BlockNumber = u64;
|
||||
@@ -18,12 +18,20 @@ pub struct NodeDetails {
|
||||
pub network_id: Option<Box<str>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub struct NodeStats {
|
||||
pub peers: u64,
|
||||
pub txcount: u64,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeIO {
|
||||
pub used_state_cache_size: MeanList<f32>,
|
||||
pub used_db_cache_size: MeanList<f32>,
|
||||
pub disk_read_per_sec: MeanList<f32>,
|
||||
pub disk_write_per_sec: MeanList<f32>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy)]
|
||||
pub struct Block {
|
||||
#[serde(rename = "best")]
|
||||
@@ -39,6 +47,17 @@ pub struct BlockDetails {
|
||||
pub propagation_time: Option<u64>,
|
||||
}
|
||||
|
||||
impl Default for BlockDetails {
|
||||
fn default() -> Self {
|
||||
BlockDetails {
|
||||
block: Block::zero(),
|
||||
block_timestamp: now(),
|
||||
block_time: 0,
|
||||
propagation_time: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NodeHardware {
|
||||
/// CPU use means
|
||||
@@ -87,6 +106,20 @@ impl Serialize for NodeStats {
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for NodeIO {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let mut tup = serializer.serialize_tuple(4)?;
|
||||
tup.serialize_element(self.used_state_cache_size.slice())?;
|
||||
tup.serialize_element(self.used_db_cache_size.slice())?;
|
||||
tup.serialize_element(self.disk_read_per_sec.slice())?;
|
||||
tup.serialize_element(self.disk_write_per_sec.slice())?;
|
||||
tup.end()
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for BlockDetails {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user