report VmRSS in metrics

main
(on company time) 2022-07-29 17:02:25 -05:00
parent 7fe4444b65
commit fff278a494
1 changed files with 13 additions and 0 deletions

View File

@ -216,10 +216,23 @@ async fn metrics (
-> Result <Response <Body>, RequestError>
{
let mut s = String::with_capacity (4 * 1_024);
s.push_str ("# HELP forty_two Forty-two\n");
s.push_str ("# TYPE forty_two counter\n");
s.push_str ("forty_two 42\n");
#[cfg (target_os = "linux")]
{
if let Some (rss) = tokio::fs::read_to_string ("/proc/self/status").await
.ok ()
.and_then (|s| get_rss_from_status (s.as_str ()))
{
s.push_str ("# HELP relay_vm_rss VmRSS of the relay process, in kB\n");
s.push_str ("# TYPE relay_vm_rss gauge\n");
s.push_str (format! ("relay_vm_rss {}\n", rss).as_str ());
}
}
Ok (Response::builder ()
.body (Body::from (s))?)
}