-
Notifications
You must be signed in to change notification settings - Fork 184
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
Push doesn't work inside tokio async block #342
Comments
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 3, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 18, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 18, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 18, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 18, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 18, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Sep 22, 2020
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Feb 20, 2021
adamchalmers
added a commit
to adamchalmers/rust-prometheus
that referenced
this issue
Feb 21, 2021
Signed-off-by: Adam Chalmers <adam.s.chalmers@gmail.com>
Actually, this is fixed in Tokio 1.0, changing the tokio = { version = "1", features = ["macros", "time", "rt-multi-thread"] } will cause the program to terminate successfully. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The
prometheus::push_metrics
function panics if called inside an async block (at least when using the Tokio runtime). It panics with the message 'Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.'I believe this is due to the use of
reqwest::blocking::Client
in the implementation. One backwards-compatible solution would be adding a newprometheus::push_metrics_async
function that usesreqwest::Client
instead. I would be happy to open a PR to add this, if you like the suggestion.To Reproduce
Minimal example to reproduce the behavior:
src/main.rs
Cargo.toml
Expected behavior
push_metrics()
does not panic when called inside an async function using Tokio.System information
The text was updated successfully, but these errors were encountered: