Skip to main content

tuwunel_admin/debug/
runtime_metrics.rs

1use tuwunel_core::Result;
2
3use crate::admin_command;
4
5#[cfg(tokio_unstable)]
6#[admin_command]
7pub(super) async fn runtime_metrics(&self) -> Result {
8	let out = self
9		.services
10		.server
11		.metrics
12		.runtime_metrics()
13		.map_or_else(
14			|| "Runtime metrics are not available.".to_owned(),
15			|metrics| {
16				format!(
17					"```rs\nnum_workers: {}\nnum_alive_tasks: {}\nglobal_queue_depth: {}\n```",
18					metrics.num_workers(),
19					metrics.num_alive_tasks(),
20					metrics.global_queue_depth()
21				)
22			},
23		);
24
25	self.write_str(&out).await
26}
27
28#[cfg(not(tokio_unstable))]
29#[admin_command]
30pub(super) async fn runtime_metrics(&self) -> Result {
31	self.write_str("Runtime metrics require building with `tokio_unstable`.")
32		.await
33}