Skip to content

Commit 97d5748

Browse files
authored
Add support for uppercase PROMETHEUS_MULTIPROC_DIR (django-commons#276)
The variable name prometheus_multiproc_dir was deprecated in django-prometheus 0.10.0 in favor of PROMETHEUS_MULTIPROC_DIR.
1 parent 48a758f commit 97d5748

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

django_prometheus/exports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def ExportToDjangoView(request):
115115
116116
You can use django_prometheus.urls to map /metrics to this view.
117117
"""
118-
if "prometheus_multiproc_dir" in os.environ:
118+
if ("PROMETHEUS_MULTIPROC_DIR" in os.environ
119+
or "prometheus_multiproc_dir" in os.environ):
119120
registry = prometheus_client.CollectorRegistry()
120121
multiprocess.MultiProcessCollector(registry)
121122
else:

documentation/exports.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ targets as you have workers, using each port separately.
7878

7979
This approach requires the application to be loaded into each child process.
8080
uWSGI and Gunicorn typically load the application into the master process before forking the child processes.
81-
Set the [lazy-apps option](https://uwsgi-docs.readthedocs.io/en/latest/Options.html#lazy-apps) to `true` (uWSGI)
81+
Set the [lazy-apps option](https://uwsgi-docs.readthedocs.io/en/latest/Options.html#lazy-apps) to `true` (uWSGI)
8282
or the [preload-app option](https://docs.gunicorn.org/en/stable/settings.html#preload-app) to `false` (Gunicorn)
83-
to change this behaviour.
83+
to change this behaviour.
8484

8585

8686
## Exporting /metrics in a WSGI application with multiple processes globally
8787

8888
In some WSGI applications, workers are short lived (less than a minute), so some
8989
are never scraped by prometheus by default. Prometheus client already provides
90-
a nice system to aggregate them using the env variable: `prometheus_multiproc_dir`
90+
a nice system to aggregate them using the env variable: `PROMETHEUS_MULTIPROC_DIR`
9191
which will configure the directory where metrics will be stored as files per process.
9292

9393
Configuration in uwsgi would look like:
9494

9595
```ini
96-
env = prometheus_multiproc_dir=/path/to/django_metrics
96+
env = PROMETHEUS_MULTIPROC_DIR=/path/to/django_metrics
9797
```
9898

9999
You can also set this environment variable elsewhere such as in a kubernetes manifest.

0 commit comments

Comments
 (0)