404 on non-metrics endpoints on metrics server (#819)

buddies-main-deployment
ember arlynx 3 years ago committed by GitHub
parent 890c5495bf
commit fdd7c64d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      rust/optics-base/src/metrics.rs

@ -172,7 +172,9 @@ impl CoreMetrics {
port = port port = port
); );
tokio::spawn(async move { tokio::spawn(async move {
warp::serve(warp::path!("metrics").map(move || { warp::serve(
warp::path!("metrics")
.map(move || {
warp::reply::with_header( warp::reply::with_header(
self.gather().expect("failed to encode metrics"), self.gather().expect("failed to encode metrics"),
"Content-Type", "Content-Type",
@ -181,7 +183,14 @@ impl CoreMetrics {
// try text/plain to make web browsers happy. // try text/plain to make web browsers happy.
"text/plain; charset=utf-8", "text/plain; charset=utf-8",
) )
})) })
.or(warp::any().map(|| {
warp::reply::with_status(
"go look at /metrics",
warp::http::StatusCode::NOT_FOUND,
)
})),
)
.run(([0, 0, 0, 0], port)) .run(([0, 0, 0, 0], port))
.await; .await;
}) })

Loading…
Cancel
Save