nlopes / actix-web-prom

Actix-web middleware to expose Prometheus metrics
MIT License
89 stars 56 forks source link

/metrics returns 404 even when it returns successfully. That 404 is not seen in /metrics output. #39

Open vbmade2000 opened 3 years ago

vbmade2000 commented 3 years ago

Description: Whenever /metrics is curled, internally it shows 404 return code even if the URL /metrics exists and gives output. Also that 404 code is not seen in /metrics output. It shows 200 only.

Rust Version: rustc 1.46.0-nightly (f781babf8 2020-07-01)

Cargo Version: cargo 1.46.0-nightly (c26576f9a 2020-06-23)

Actix Web Version: 3.1.0

actix-web-prom Version: 0.5.0

dpn commented 3 years ago

Reordering the .wrap calls to do prom first then the logger fixes this up for me so may be worth a shot for you if your ordering is flipped as well. Sorry too lazy to root around through the code to understand why.

let prometheus = PrometheusMetrics::new("api", Some("/metrics"), Some(labels));
HttpServer::new(move || {
    App::new()
        .wrap(prometheus.clone())
        .wrap(Logger::default())
        .service(web::resource("/health").to(health))
})
.bind("127.0.0.1:8080")?
.run()
.await?;
vladvasiliu commented 3 years ago

There's definitely an issue somewhere. Using NormalizePath middleware returns 404, but there's no output.

vbmade2000 commented 2 years ago

@dpn I'll check your solution. Thanks.

dpn commented 2 years ago

https://github.com/actix/examples/blob/master/basics/basics/src/main.rs#L74 🤷