rust-prometheus icon indicating copy to clipboard operation
rust-prometheus copied to clipboard

push metrics: Please expose functionality to get push url and encoded metrics (without push feature)

Open aawsome opened this issue 11 months ago • 1 comments

Is your feature request related to a problem? Please describe. We would like to push metrics to a pushgateway. The push feature however is quite restricted to a special reqwest configuration which does not comply to our dependency situation

Describe the solution you'd like Within the code in https://github.com/tikv/rust-prometheus/blob/master/src/push.rs#L80, most work involves creating the exact url to use and to create and validate the encoded metrics. I wonder if we could simply refactor this in its own public function which is independent from the push feature, meaning which does not involve any external dependency.

Describe alternatives you've considered There is the crate prometheus-push but is has its own compromises and pulls other dependencies. An alternative would be to add similar functionality to this crate.

The solution I have currently chosen is to copy&paste the code into my own codebase.

aawsome avatar Feb 07 '25 13:02 aawsome

Just to suggest an alternative, also coming from the same place: I think if the push feature could require reqwest with default-features = false, it would also solve the issue.

This way, users who want it could add native-tls, while users who don't want to require libssl-dev could eg. enable rustls on reqwest.

WDYT?

Ekleog avatar Feb 07 '25 14:02 Ekleog