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

Fix #342: Async support for push_metrics #343

Closed
wants to merge 1 commit into from

Conversation

adamchalmers
Copy link

@adamchalmers adamchalmers commented Sep 3, 2020

I tried to document the problem thoroughly on the issue itself. This is a proposed solution. I tried to share as much code as I could between push_async and push. Let me know if you'd rather I take a different approach!

Fixes: #342

Copy link
Contributor

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for both tracing this bug all the way down as well as proposing a bug fix.

I am likely the wrong maintainer to review this pull request as (a) I am not a user of pushing metrics to a Prometheus server and (b) I am of the opinion that pushing metrics is out of scope for this library.

With that in mind I would prefer another maintainer to get involved as well.

src/push.rs Outdated Show resolved Hide resolved
src/push.rs Show resolved Hide resolved
@mxinden
Copy link
Contributor

mxinden commented Sep 4, 2020

Fixes #342

Properly linking back to the detailed bug report.

@adamchalmers
Copy link
Author

Tagging @koushiro @breeswish for review :)

README.md Outdated Show resolved Hide resolved
@adamchalmers
Copy link
Author

@mxinden @breeswish Hi! Just pinging y'all for another review :)

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I have left a few comments.

README.md Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
handle_push_response(response.status(), push_url)
}

async fn push_async<S: BuildHasher>(
Copy link
Member

@breezewish breezewish Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is very similar to fn push. Is it possible to use something like https://docs.rs/crate/reqwest/0.10.8/source/src/blocking/wait.rs to share common logic between the async impl and blocking impl?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what the linked code has to do with duplication. I tried to reduce duplication as much as possible by breaking common code into their own functions which are called inside both async_push and push. But this can only go so far, because the underlying reqwest structs use different types.

Signed-off-by: Adam Chalmers <adam.s.chalmers@gmail.com>
@adamchalmers
Copy link
Author

Sorry I forgot about this for so many months. I've addressed most of the feedback except the one comment I didn't understand. I'd like to get this merged, because my project is stuck on Prometheus 0.7, which means I'm stuck pulling in an insecure version of Hyper (via reqwest), which means that my work's CI blocks builds. I can always fork this repo until the PR is merged, but I'd rather get this addressed :)

@adamchalmers
Copy link
Author

PR is no longer necessary because I realized that Tokio 1.0 doesn't clash with reqwest::blocking!

@adamchalmers
Copy link
Author

adamchalmers commented Mar 5, 2021

Actually, the latest reqwest 0.11 and the latest tokio 1 are incompatible again. I think this PR is ultimately the best way forward, that way projects which use rust-prometheus can make their own choice of async or blocking. Apologies for all the back-and-forth on this.

@WaffleLapkin
Copy link

What's the status of this PR? It seems odd, to not provide an async interface when using reqwest. Calling blocking code (especially something like an HTTP client) from async is never a good idea.

@ashlineldridge
Copy link

ashlineldridge commented May 23, 2022

Any update on this PR? Would be great to see this functionality land 🙏🏼

@adamchalmers
Copy link
Author

I agree, it would be great for one of the maintainers to review this and tell me what is blocking merge.

@adamchalmers
Copy link
Author

Closing as apparently no maintainers want this reviewed. Ping me if you want it reopened.

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

Successfully merging this pull request may close these issues.

Push doesn't work inside tokio async block
6 participants