root: don't force multiprocess prometheus registry

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-04-29 10:53:47 +02:00
parent 79caba45cc
commit cd1d1b4402
1 changed files with 3 additions and 7 deletions

View File

@ -1,15 +1,14 @@
"""Metrics view"""
from base64 import b64encode
import prometheus_client
from django.conf import settings
from django.db import connections
from django.db.utils import OperationalError
from django.dispatch import Signal
from django.http import HttpRequest, HttpResponse
from django.views import View
from django_prometheus.exports import ExportToDjangoView
from django_redis import get_redis_connection
from prometheus_client import multiprocess
from redis.exceptions import RedisError
monitoring_set = Signal()
@ -32,12 +31,9 @@ class MetricsView(View):
monitoring_set.send_robust(self)
registry = prometheus_client.CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
try:
metrics_page = prometheus_client.generate_latest(registry)
return HttpResponse(metrics_page, content_type=prometheus_client.CONTENT_TYPE_LATEST)
except (UnicodeDecodeError, KeyError):
return ExportToDjangoView(request)
except (UnicodeDecodeError, KeyError, ValueError):
return HttpResponse(status_code=500)