use crate::debug::Diagnostic;
use bytes::Bytes;
use conjure_error::Error;
use http::HeaderValue;
use tikv_jemalloc_ctl::stats_print;
pub struct HeapStatsDiagnostic;
impl Diagnostic for HeapStatsDiagnostic {
fn type_(&self) -> &str {
"rust.heap.stats.v1"
}
fn content_type(&self) -> HeaderValue {
HeaderValue::from_static("text/plain")
}
fn safe_loggable(&self) -> bool {
true
}
fn result(&self) -> Result<Bytes, Error> {
let mut buf = vec![];
stats_print::stats_print(&mut buf, stats_print::Options::default())
.map_err(Error::internal_safe)?;
Ok(Bytes::from(buf))
}
}