reminder-bot/web/src/routes/metrics.rs
jude 6e435bfc2e Add metrics
Change dashboards to load an index.html file compiled otherwise
2023-11-12 10:13:12 +00:00

19 lines
382 B
Rust

use prometheus;
use crate::metrics::REGISTRY;
#[get("/metrics")]
pub async fn metrics() -> String {
let encoder = prometheus::TextEncoder::new();
let res_custom = encoder.encode_to_string(&REGISTRY.gather());
match res_custom {
Ok(s) => s,
Err(e) => {
warn!("Error encoding metrics: {:?}", e);
String::new()
}
}
}