root: don't force multiprocess prometheus registry
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
79caba45cc
commit
cd1d1b4402
|
@ -1,15 +1,14 @@
|
||||||
"""Metrics view"""
|
"""Metrics view"""
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
|
|
||||||
import prometheus_client
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
from django.db.utils import OperationalError
|
from django.db.utils import OperationalError
|
||||||
from django.dispatch import Signal
|
from django.dispatch import Signal
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
from django_prometheus.exports import ExportToDjangoView
|
||||||
from django_redis import get_redis_connection
|
from django_redis import get_redis_connection
|
||||||
from prometheus_client import multiprocess
|
|
||||||
from redis.exceptions import RedisError
|
from redis.exceptions import RedisError
|
||||||
|
|
||||||
monitoring_set = Signal()
|
monitoring_set = Signal()
|
||||||
|
@ -32,12 +31,9 @@ class MetricsView(View):
|
||||||
|
|
||||||
monitoring_set.send_robust(self)
|
monitoring_set.send_robust(self)
|
||||||
|
|
||||||
registry = prometheus_client.CollectorRegistry()
|
|
||||||
multiprocess.MultiProcessCollector(registry)
|
|
||||||
try:
|
try:
|
||||||
metrics_page = prometheus_client.generate_latest(registry)
|
return ExportToDjangoView(request)
|
||||||
return HttpResponse(metrics_page, content_type=prometheus_client.CONTENT_TYPE_LATEST)
|
except (UnicodeDecodeError, KeyError, ValueError):
|
||||||
except (UnicodeDecodeError, KeyError):
|
|
||||||
return HttpResponse(status_code=500)
|
return HttpResponse(status_code=500)
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue