Closed Ploppz closed 2 years ago
I just verified this. Fix incoming within the next few days.
Can you try with https://github.com/nlopes/actix-web-prom/pull/61?
Would love to see if it fixes your issues.
Thanks. I tried but I can't proceed to make it work due to https://github.com/actix/actix-web/issues/2533 And in my application I cannot seem to find a combination of version numbers (or git rev) for actix-web, actix-cors, actix-rt, actix-web-prom, and actix-web-middleware-keycloak-auth, that work together. Edit: I did find a combination that works per dependency resolution but still running into aforementioned issue.
Alright I got the dependency puzzle working. Now I have one problem with prometheus:
error[E0271]: type mismatch resolving `<<impl ServiceFactory<ServiceRequest> as ServiceFactory<ServiceRequest>>::Service as actix_web::dev::Service<ServiceRequest>>::Response == ServiceResponse`
--> src/main.rs:194:19
|
194 | .wrap(prometheus.clone())
| ---- ^^^^^^^^^^^^^^^^^^ expected enum `EitherBody`, found struct `BoxBody`
| |
| required by a bound introduced by this call
|
= note: expected struct `ServiceResponse<EitherBody<BoxBody>>`
found struct `ServiceResponse<BoxBody>`
= note: required because of the requirements on the impl of `Transform<<impl ServiceFactory<ServiceRequest> as ServiceFactory<ServiceRequest>>::Service, ServiceRequest>` for `PrometheusMetrics`
(where prometheus: PrometheusMetrics
)
Relevant dependencies:
actix-web = "=4.0.0-beta.14"
actix-http = "=3.0.0-beta.15" # Only in order to pin the dep - TODO remove when actix-web 4 is released
actix-web-prom = { git = "https://github.com/nlopes/actix-web-prom.git", branch = "nlopes/bump-to-actix-web-14" }
prometheus = "0.13.0"
I don't know how helpful it is to mention, but I'm seeing the same issue as @Ploppz after resolving the dependency mismatches
@nlopes is there any progress on this? also running into this
@nlopes is there any progress on this? also running into this
Is this with the branch nlopes/bump-to-actix-web-14
? If it is, would you mind pointing me to an open source repo where I can replicate the issue?
@nlopes indeed there are 2 issues with it:
1) doesn't work with the latest beta, AnyBody no longer exists 2) trying to pass it as a middleware doesn't work, the type doesn't match
as for an open source repo, does this one count? the example in the readme is enough to trigger both problems
@AEnterprise do you mind telling me your rust version? As it stands, I can run all of the examples. For ease of debugging this, I've added all 3 examples from the README to an examples/ folder. Can you run each one (and for which rust version) and provide the output?
with the update to that branch the examples work again, thanks!
The examples run fine, but in my application I get
error[E0271]: type mismatch resolving `<<impl ServiceFactory<ServiceRequest> as ServiceFactory<ServiceRequest>>::Service as actix_web::dev::Service<ServiceRequest>>::Response == ServiceResponse`
--> src/main.rs:194:19
|
194 | .wrap(prometheus.clone())
| ---- ^^^^^^^^^^^^^^^^^^ expected enum `EitherBody`, found struct `BoxBody`
| |
| required by a bound introduced by this call
|
= note: expected struct `ServiceResponse<EitherBody<BoxBody>>`
found struct `ServiceResponse<BoxBody>`
= note: required because of the requirements on the impl of `Transform<<impl ServiceFactory<ServiceRequest> as ServiceFactory<ServiceRequest>>::Service, ServiceRequest>` for `PrometheusMetrics`
I tried my best to lock the right versions of all relevant deps:
actix-web = "=4.0.0-beta.16"
actix-http = "=3.0.0-beta.17"
actix-web-prom = { git = "https://github.com/nlopes/actix-web-prom.git", branch = "nlopes/bump-to-actix-web-14" }
prometheus = "0.13.0"
Any idea how I can fix this?
Can you show a bit more of the surrounding code there? Or point me to a commit somewhere where I can take a look if possible. Would love to help but I'm a bit at a loss at this point.
I managed to make a minimal example. The problem only arises when actix_cors::Cors
is wrapped before the middleware of this crate.
[dependencies]
actix-web = "=4.0.0-beta.19"
actix-http = "=3.0.0-beta.18"
actix-rt = "2.5"
actix-web-prom = { git = "https://github.com/nlopes/actix-web-prom.git", branch = "nlopes/bump-to-actix-web-14" }
actix-cors = "0.6.0-beta.7"
prometheus = "0.13.0"
main.rs:
use actix_web::{App, HttpServer};
use actix_web_prom::PrometheusMetricsBuilder;
use prometheus::Registry;
#[actix_rt::main]
async fn main() {
let registry = Registry::new();
let prometheus = PrometheusMetricsBuilder::new("public_api")
.endpoint("/api/v1/metrics")
.registry(registry)
.build()
.unwrap();
HttpServer::new(move || {
App::new()
.wrap(
actix_cors::Cors::permissive()
.allowed_methods(vec!["GET", "POST", "PUT", "OPTIONS", "DELETE"])
.max_age(3600),
)
.wrap(prometheus.clone())
})
.bind("")
.unwrap()
.run()
.await;
}
Fixed if I reorder my middlewares. I guess it's an issue in actix_cors
?
It might also be here. This is great to know. I'll take a look this weekend just to ensure I'm not doing something silly that's preventing another middleware from working.
To reproduce the issue I'm having, create a new crate with the following dependencies (possibly not all required)
It gives the following compiler error:
rustc: