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. 29
      rust/optics-base/src/metrics.rs

@ -172,16 +172,25 @@ impl CoreMetrics {
port = port port = port
); );
tokio::spawn(async move { tokio::spawn(async move {
warp::serve(warp::path!("metrics").map(move || { warp::serve(
warp::reply::with_header( warp::path!("metrics")
self.gather().expect("failed to encode metrics"), .map(move || {
"Content-Type", warp::reply::with_header(
// OpenMetrics specs demands "application/openmetrics-text; version=1.0.0; charset=utf-8" self.gather().expect("failed to encode metrics"),
// but the prometheus scraper itself doesn't seem to care? "Content-Type",
// try text/plain to make web browsers happy. // OpenMetrics specs demands "application/openmetrics-text; version=1.0.0; charset=utf-8"
"text/plain; charset=utf-8", // but the prometheus scraper itself doesn't seem to care?
) // try text/plain to make web browsers happy.
})) "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