Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/metrics endpoint is resolving but no metrics are displayed #21

Open
mark-e-hoffman opened this issue Jun 22, 2023 · 4 comments
Open

/metrics endpoint is resolving but no metrics are displayed #21

mark-e-hoffman opened this issue Jun 22, 2023 · 4 comments

Comments

@mark-e-hoffman
Copy link

I'm using version = "0.10.0-rc.3" and my rocket webserver will resolve /metrics but there is no data returned, even though I have sent several GET AND POST requests to my server.

rocket::build()
.attach(AdHoc::config::())
.manage(pool)
.manage(replier)
.manage(prometheus.clone())
.manage(amqp_pool)
.attach(rocket_governor::LimitHeaderGen::default())
.register("/", catchers!(rocket_governor_catcher)) // catches limit errors and produces a 429 error code
.mount("/ref", routes![refs::get,refs::patch, refs::delete, refs::post, refs::get_all])
.mount("/device", routes![device::get,device::patch, device::delete, device::post, device::get_all])
.mount("/library", routes![library::get,library::patch, library::delete, library::post, library::get_all, library::link_ref_item_to_library, library::get_ref_item_in_library])
.mount("/session", routes![session::get,session::patch, session::delete, session::post, session::get_all])
.mount("/project", routes![project::get,project::patch, project::delete, project::post, project::get_all,project::link_library_to_project, project::get_library_in_project,project::match_detections])
.mount("/metrics", prometheus)
.launch().await?;

@sd2k
Copy link
Owner

sd2k commented Jun 22, 2023

I can't see anything wrong with your setup in the code snippet you've posted, but it's difficult to reproduce such a complicated example. I've never noticed any issues like that in my apps. The only thing I can think of is to try changing the order of your mounts: perhaps the .register("/", catchers!(rocket_governor_catcher) should be after the .mount() calls?

@mark-e-hoffman
Copy link
Author

mark-e-hoffman commented Jun 22, 2023 via email

@Rauks
Copy link

Rauks commented Sep 29, 2023

Hi,

I encountered the same issue, and made the same mistake than you @mark-e-hoffman 😄

You added the prometheus fairing as a managed state (https://rocket.rs/v0.5-rc/guide/state/#managed-state) by doing:

.manage(prometheus.clone())

You should use attach to attach the fairing instead (https://rocket.rs/v0.5-rc/guide/fairings/#fairings):

.attach(prometheus.clone())

@sd2k
Copy link
Owner

sd2k commented Sep 29, 2023

Good catch @Rauks! Thanks for replying here, glad you found the cause. I'm not even sure there's a good way of avoiding that, unless I split the struct up into 2 somehow... I'll give it some thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants