Skip to content

Commit ea68d97

Browse files
authored
Merge branch 'korfuri:master' into master
2 parents 2d99031 + 46f6053 commit ea68d97

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

django_prometheus/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Import all files that define metrics. This has the effect that
77
# `import django_prometheus` will always instantiate all metric
88
# objects right away.
9+
import django
910
from django_prometheus import middleware, models
1011

1112
__all__ = ["middleware", "models", "pip_prometheus"]
@@ -19,4 +20,5 @@
1920
# If people don't have pip, don't export anything.
2021
pass
2122

22-
default_app_config = "django_prometheus.apps.DjangoPrometheusConfig"
23+
if django.VERSION < (3, 2):
24+
default_app_config = "django_prometheus.apps.DjangoPrometheusConfig"

documentation/exports.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ This will make Django-Prometheus try to export /metrics on port
7676
You can then configure Prometheus to collect metrics on as many
7777
targets as you have workers, using each port separately.
7878

79+
This approach requires the application to be loaded into each child process.
80+
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)
82+
or the [preload-app option](https://docs.gunicorn.org/en/stable/settings.html#preload-app) to `false` (Gunicorn)
83+
to change this behaviour.
84+
85+
7986
## Exporting /metrics in a WSGI application with multiple processes globally
8087

8188
In some WSGI applications, workers are short lived (less than a minute), so some

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ django-redis>=4.12.1
22
black; python_version >= '3.6'
33
flake8
44
isort>=5.5.4,<6
5-
prometheus-client>=0.7
5+
prometheus-client>=0.9.0
66
pip-prometheus>=1.2.1
77
mysqlclient
88
psycopg2
9-
pytest>=6.1.1,<7
9+
pytest==6.2.3
1010
pytest-django
1111
python-memcached

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {py36,py37,py38}-django{220,300,310}-{end2end,unittests},py38-lint
2+
envlist = {py36,py37,py38}-django{220,300,310,320}-{end2end,unittests},py38-lint
33

44
[testenv]
55
deps =

0 commit comments

Comments
 (0)