Add TaskMonitor interval metrics w/ admin command.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -22,6 +22,7 @@ use tuwunel_core::{
|
||||
Event,
|
||||
pdu::{PduEvent, PduId, RawPduId},
|
||||
},
|
||||
tokio_metrics::TaskMonitor,
|
||||
trace, utils,
|
||||
utils::{
|
||||
stream::{IterStream, ReadyExt},
|
||||
@@ -790,6 +791,37 @@ pub(super) async fn runtime_interval(&self) -> Result {
|
||||
.await
|
||||
}
|
||||
|
||||
#[admin_command]
|
||||
pub(super) async fn task_metrics(&self) -> Result {
|
||||
let out = self
|
||||
.services
|
||||
.server
|
||||
.metrics
|
||||
.task_metrics()
|
||||
.map(TaskMonitor::cumulative)
|
||||
.map_or_else(
|
||||
|| "Task metrics are not available.".to_owned(),
|
||||
|metrics| format!("```rs\n{metrics:#?}\n```"),
|
||||
);
|
||||
|
||||
self.write_str(&out).await
|
||||
}
|
||||
|
||||
#[admin_command]
|
||||
pub(super) async fn task_interval(&self) -> Result {
|
||||
let out = self
|
||||
.services
|
||||
.server
|
||||
.metrics
|
||||
.task_interval()
|
||||
.map_or_else(
|
||||
|| "Task metrics are not available.".to_owned(),
|
||||
|metrics| format!("```rs\n{metrics:#?}\n```"),
|
||||
);
|
||||
|
||||
self.write_str(&out).await
|
||||
}
|
||||
|
||||
#[admin_command]
|
||||
pub(super) async fn time(&self) -> Result {
|
||||
let now = SystemTime::now();
|
||||
|
||||
@@ -197,6 +197,13 @@ pub(super) enum DebugCommand {
|
||||
/// invocation.
|
||||
RuntimeInterval,
|
||||
|
||||
/// - Print detailed tokio task metrics accumulated in total.
|
||||
TaskMetrics,
|
||||
|
||||
/// - Print detailed tokio task metrics accumulated since last command
|
||||
/// invocation.
|
||||
TaskInterval,
|
||||
|
||||
/// - Print the current time
|
||||
Time,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user