add stats metrics (#1207)

support new cli command `easytier-cli stats`

It's useful to find out which components are consuming bandwidth.
This commit is contained in:
Sijie.Sun
2025-08-09 00:06:35 +08:00
committed by GitHub
parent efa17a7c10
commit 8cdb27d43d
15 changed files with 1442 additions and 19 deletions
+10 -1
View File
@@ -4,7 +4,7 @@ use futures::{SinkExt as _, StreamExt};
use tokio::task::JoinSet;
use crate::{
common::{error::Error, PeerId},
common::{error::Error, PeerId, stats_manager::StatsManager},
proto::rpc_impl::{self, bidirect::BidirectRpcManager},
tunnel::packet_def::ZCPacket,
};
@@ -47,6 +47,15 @@ impl PeerRpcManager {
}
}
pub fn new_with_stats_manager(tspt: impl PeerRpcManagerTransport, stats_manager: Arc<StatsManager>) -> Self {
Self {
tspt: Arc::new(Box::new(tspt)),
bidirect_rpc: BidirectRpcManager::new_with_stats_manager(stats_manager),
tasks: Mutex::new(JoinSet::new()),
}
}
pub fn run(&self) {
let ret = self.bidirect_rpc.run_and_create_tunnel();
let (mut rx, mut tx) = ret.split();