Skip to content

Commit d0b7a80

Browse files
committed
Add support for exporting prometheus metrics
1 parent b51329e commit d0b7a80

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ bleach==6.0.0
1616
requests==2.32.0
1717
xtarfile==0.1.0
1818
zstandard==0.17.0
19+
django-prometheus==2.3.1

settings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
DEBUG = False
77
DEBUG_TOOLBAR = False
88

9+
# Export prometheus metrics
10+
PROMETHEUS_METRICS = False
11+
912
# Notification admins
1013
ADMINS = ()
1114

@@ -265,4 +268,9 @@
265268

266269
INSTALLED_APPS = [*list(INSTALLED_APPS), 'debug_toolbar']
267270

271+
if PROMETHEUS_METRICS:
272+
MIDDLEWARE = ['django_prometheus.middleware.PrometheusBeforeMiddleware', *list(MIDDLEWARE), 'django_prometheus.middleware.PrometheusAfterMiddleware']
273+
274+
INSTALLED_APPS = [*list(INSTALLED_APPS), 'django_prometheus']
275+
268276
# vim: set ts=4 sw=4 et:

urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@
114114
path('__debug__/', include(debug_toolbar.urls)),
115115
])
116116

117+
# prometheus metrics
118+
if settings.PROMETHEUS_METRICS: # pragma :no cover
119+
urlpatterns.extend([
120+
path('', include('django_prometheus.urls')),
121+
])
122+
117123

118124
# displays all archweb urls
119125
def show_urls(urllist=urlpatterns, depth=0): # pragma: no cover

0 commit comments

Comments
 (0)