Prometheus middleware improvements #627
Open
+154
−42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A number of Prometheus middleware improvements:
Have successfully run
pytest --benchmark-skip
on my local python 3.10.14.Some details below.
Canonical queue names
If queue names aren't canonical, then something like this happens to metrics:
Unique PROMETHEUS_MULTIPROC_DIR
Previously, Prometheus mutli-proc exporting would interfere between multiple Dramatiq instances on the same machine (because the prom DB path would be the same across different instances). Actually, would interfere even across restarts of the same Dramatiq instance (and even in containerized environments, when containers are just restarted, and not recreated).
In containerized env, top-level PID value is likely to be the same across runs, but with auto-cleanup it can be managed.
Metrics test
Noticed that
test_prometheus_middleware_exposes_metrics
was sometimes failing due to timings - metrics endpoint wasn't ready in 1 second. Should be a bit more stable now.