-
Notifications
You must be signed in to change notification settings - Fork 188
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_metrics
panics inside tokio
#453
Comments
It's quite simple to make it work, basically just need to not use
|
Thanks for the report. Have you perhaps tried the features-set described in #342 (comment) already? |
Hello, thanks for the reply. Just tried here, but the same error occurs. |
FWIW, the original fix no longer works. It's failing on the latest tokio (1.23.0) as far as I can tell. |
I wrote prometheus-push as a crate that handles the push functionality, so For this crate and non blocking [dependencies]
prometheus_push = { version = "<version>", default-features = false, features = ["with_reqwest", "prometheus_crate"] } use prometheus::labels;
use prometheus_push::prometheus_crate::PrometheusMetricsPusher;
use reqwest::Client;
use url::Url;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let push_gateway: Url = Url::parse("<address to pushgateway>")?;
let client = Client::new();
let metrics_pusher = PrometheusMetricsPusher::from(client, &push_gateway)?;
metrics_pusher
.push_all(
"<your push jobs name>",
&labels! { "<label_name>" => "<label_value>" },
prometheus::gather(),
)
.await?;
Ok(())
} |
Describe the bug
Calling
push_metrics
from anasync
function withtokio
causes this error:To Reproduce
Take the push example, annotate
main
with#[tokio::main]
, usingtokio = { version = "1.20", features = ["rt", "rt-multi-thread", "macros"] }
in theCargo.toml
. Running the example will produce the error above.Expected behavior
No panic or
async
-compatible alternative.The text was updated successfully, but these errors were encountered: