Repository navigation
make Prometheus optional - #688
Conversation
- prometheus-client is now an optional dependency - The Prometheus middleware is only loaded if the prometheus_client is installed.
|
|
||
|
|
||
| dependencies = [ | ||
| "prometheus-client>=0.2", |
There was a problem hiding this comment.
This would technically be a breaking change to the build process for people who use Dramatiq, so I'm not sure what to do about it. Is there a way to specify negative dependencies in setup.py? Eg., pip install dramatiq[no-prometheus]. If so, that's the way we should go.
There was a problem hiding this comment.
I am not sure that there is a thing such as negative dependencies. I think this is covered by PEP771 but this is still a draft at the moment.
Removing prometheus-client is indeed a breaking change, and I am not sure how this could be otherwise. Usually such changes come with deprecation warnings, but in the case of dependencies, I don't know how to raise a deprecation warning for users that use the middleware but have not explicitly added its extra.
The only remaining option I see is good communication on the changelog.
|
|
||
| try: | ||
| if importlib.util.find_spec("prometheus_client"): | ||
| default_middleware.insert(0, Prometheus) |
There was a problem hiding this comment.
My suggestion: if we are going to make a breaking change release removing Prometheus from the default middleware, we should also remove this line. In case there is someone who wants to install this library, but doesn't want the middleware.
i.e. the default_middleware list shouldn't change depending on what libraries you have installed.
There was a problem hiding this comment.
@Bogdanp, do you have an opinion about this?
There was a problem hiding this comment.
I think @LincolnPuzey 's suggestion makes a lot of sense if we are making a breaking change.
My preference, as always, is not to make breaking changes. But, maybe I am being too dogmatic on this point and it doesn't matter that much in this particular case. I would love it if folks who operate Dramatiq in production would weigh in and let us know what they think.
|
Hi @frankie567 @oYASo @sfahad1414 @SamR1 @mhdzumair I apologize for the ping. We would like some advice on your usage of dramatiq, and especially if you have an opinion about removing prometheus as a required dependency.
I summoned you because your projects are the most popular from the dramatiq dependency graph. Any thoughts on the matter? |
|
Thank you @azmeuk for asking, really appreciate it! In my opinion, making Prometheus optional is definitely the right move. Not everyone needs or uses Prometheus metrics, so having it by default is a bit surprising, especially since it opens an HTTP server (quite silently besides that). Of course, it's nice to have it as a built-in middleware we can enable at will 🙂 In our case, we don't really consume the Prometheus metrics: we use it as a quick and dirty health check endpoint. It could be nice to have a middleware exposing a simple health endpoint for this purpose. |
|
You can make it optional. |
|
Yes @azmeuk can be made optional. |
|
Thank you all for your answers! @Bogdanp do you need more feedback? I can post something on the ML if you want. |
|
Yes, let's do a post on the mailing list and if no one objects within a week or so we can go ahead with this. Thanks for your work on this! |
|
I just sent a message on the ML. |
|
Need changes at doc? https://dramatiq.io/advanced.html#prometheus-metrics |
|
I get around some of this problem by specifying all middleware explicitly, as a list - maybe the docs should also move this direction. It won't solve the issue of the prometheus dep being added but at least users following the docs will be able to easily remove its middleware. |
|
@guedesfelipe you mean adding a note to indicate that Prometheus must be installed as an extra? @karolinepauls could it is the subject of another PR? |
Something like that. And add an error when importing the prometheus client if it is not installed correctly? |
|
@azmeuk, how do they feel on the ML? I'd like to see this merged soon, was really hoping it could land in 1.18.0 already. |
@guedesfelipe Isn't the natural
@KrilleGH the ML has been quiet, so no one has raised objections. @Bogdanp, what do you think? |
I think what's suggested is how FastAPI does it. When only installing It could be nicer to have a verbose message in this case as well. |
Yeaah! That's it! Explicit is better than implicit Tnx @KrilleGH |
|
Thanks @azmeuk for carrying this through! |
|
One detail @Bogdanp, the changelog entry is displayed 1.17.1 instead of 1.18. |
Thanks for the heads-up. I've pushed a follow-up change to move it under Unreleased. |
|
@Bogdanp, can we have a release including this PR? |
|
@KrilleGH |
|
Any version release estimates? @karolinepauls |
* chore: make Prometheus optional - prometheus-client is now an optional dependency - The Prometheus middleware is only loaded if the prometheus_client is installed. * chore: changelog * fix: insert prometheus middleware at the beginning of the default_middleware list * feat: remove Prometheus from the default middlewares * doc: changelog update
|
I am getting error if I import Prometheus middleware directly with installed prometheus-client. It's a little confusing |
|
Question: is the Prometheus middleware missing here dramatiq/dramatiq/middleware/__init__.py Lines 20 to 52 in 4a5ca3e |
I applied the patch proposed in #345 to make the Prometheus middleware optional:
fixes #345