Last active
October 10, 2018 01:44
-
-
Save heavypackets/c38f900472c9907b5c078b1af92549fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
... | |
let mut metrics_router = Router::new(); | |
metrics_router.get("/metrics", metrics, "get_metrics"); | |
let _metrics = Iron::new(metrics_router).http("127.0.0.1:3001"); | |
audit_event( | |
ServerEvents::Start, | |
&format!("New instance of secret-server started: {}", *SPIFFE_ID), | |
); | |
} | |
... | |
fn metrics(_req: &mut Request) -> IronResult<Response> { | |
let metric_families = prometheus::gather(); | |
let mut buffer = vec![]; | |
match prometheus_encoder.encode(&metric_families, &mut buffer) { | |
Ok(_) => Ok(Response::with((iron::status::Ok, buffer))), | |
Err(e) => { | |
eprintln!("Unable to encode prometheus metrics: {}", e.to_string()); | |
Ok(Response::with(iron::status::InternalServerError)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment