I wanted to monitor my django app with prometheus and I added the django-prometheus(2.1.0) and then all my requests, except /metrics
causes 500 when DEBUG=FALSE
. I can't understand why it's only working with DEBUG=TRUE
.
# 'django_prometheus.middleware.PrometheusBeforeMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# 'django_prometheus.middleware.PrometheusAfterMiddleware',
Is there anything wrong with my middlewares?
----- Update:
The only other thing which I've done when DEBUG=FALSE
is:
if not DEBUG:
sentry_sdk.init(
"<sentry_url>",
integrations=[DjangoIntegration()]
)
I also have used django_prometheus.models.ExportModelOperationsMixin
for my models.
related requirements version:
sentry-sdk==0.14.3
django-prometheus==2.1.0