Skip to content

Commit

Permalink
Specific endpoint for prometheus exporter health checking (metrics-rs…
Browse files Browse the repository at this point in the history
  • Loading branch information
biancamip committed Jan 14, 2024
1 parent 27a5ff3 commit a83f591
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions metrics-exporter-prometheus/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,15 @@ impl PrometheusBuilder {
let handle = handle.clone();

async move {
Ok::<_, hyper::Error>(service_fn(move |_| {
Ok::<_, hyper::Error>(service_fn(move |req| {
let handle = handle.clone();

async move {
if is_allowed {
let output = handle.render();
Ok::<_, hyper::Error>(Response::new(Body::from(output)))
Ok::<_, hyper::Error>(match req.uri().path() {
"/health" => Response::new(Body::from("OK")),
_ => Response::new(Body::from(handle.render())),
})
} else {
Ok::<_, hyper::Error>(
Response::builder()
Expand Down

0 comments on commit a83f591

Please sign in to comment.