rycus86 / prometheus_flask_exporter

Prometheus exporter for Flask applications
https://pypi.python.org/pypi/prometheus-flask-exporter
MIT License
646 stars 161 forks source link

refactor: Use f-strings and simplify operations #136

Closed kkirsche closed 1 year ago

kkirsche commented 2 years ago

This replaces the use of lower-performance interpolation with f-strings and simplifies conditionals and file reading to match the supported Python versions as per the README.md badges

coveralls commented 2 years ago

Coverage Status

Coverage: 84.526%. Remained the same when pulling 5f005f2c2f0b689973fd800b830ca916ab6a7e31 on kkirsche:refactor into 200fb9ad2fc7e642b8c4d11738fd4d6bb626aa22 on rycus86:master.

rycus86 commented 2 years ago

Thanks for this @kkirsche ! It looks like this breaks tests on older Python versions. I wanted to align with Flask and prometheus_client here, so maybe it's time to drop Python 2 support and the oldest 3.x, but haven't started working on it yet - we should be able to drop a bit of compatibility code there as well

kkirsche commented 2 years ago

Personally, I think because 2.x is end of life, many of the major libraries have dropped support, and 3.11 in October will be faster than 2.x had been, it's time to just drop comparability and embrace modern versions.

While 2.x support was important, developers have had nearly 14 years since 3.0's release to migrate. I think it's important to stop encouraging developers to hold off upgrading any longer.

kkirsche commented 2 years ago

To your point, currently flask requires Python 3.7+ while client_Python in Prometheus requires 3.6+. If you want to use data classes or some of the typing module, 3.7 may make more sense as a target, otherwise 3.6 is pretty similar (outside of asyncio)

kkirsche commented 1 year ago

Wanted to sync up on this again now that 0.22.0 has removed support for 3.6

rycus86 commented 1 year ago

Hello! Yeah, I think it's time now to do this. Could you please rebase this PR on top of the latest changes? I can then run it through actions and cut a release. Thanks!

kkirsche commented 1 year ago

Of course, I believe I have rebased against the latest master branch. If you have any questions or encounter any issues, just let me know 🙂

kkirsche commented 1 year ago

Thank you for your time, patience and help. If there are any changes that would be of use that you may not have time to work on, feel free to let me know 👍

rycus86 commented 1 year ago

No, thank you for your contribution! Improvements are always welcome!