Add support for exporting prometheus metrics

This commit is contained in:
Jelle van der Waa 2024-07-22 21:30:28 +02:00 committed by Jelle van der Waa
parent b51329eeeb
commit d0b7a80077
3 changed files with 15 additions and 0 deletions

View File

@ -16,3 +16,4 @@ bleach==6.0.0
requests==2.32.0
xtarfile==0.1.0
zstandard==0.17.0
django-prometheus==2.3.1

View File

@ -6,6 +6,9 @@
DEBUG = False
DEBUG_TOOLBAR = False
# Export prometheus metrics
PROMETHEUS_METRICS = False
# Notification admins
ADMINS = ()
@ -265,4 +268,9 @@
INSTALLED_APPS = [*list(INSTALLED_APPS), 'debug_toolbar']
if PROMETHEUS_METRICS:
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware', *list(MIDDLEWARE), 'django_prometheus.middleware.PrometheusAfterMiddleware']
INSTALLED_APPS = [*list(INSTALLED_APPS), 'django_prometheus']
# vim: set ts=4 sw=4 et:

View File

@ -114,6 +114,12 @@
path('__debug__/', include(debug_toolbar.urls)),
])
# prometheus metrics
if settings.PROMETHEUS_METRICS: # pragma :no cover
urlpatterns.extend([
path('', include('django_prometheus.urls')),
])
# displays all archweb urls
def show_urls(urllist=urlpatterns, depth=0): # pragma: no cover