Skip to content

Commit

Permalink
Add support for exporting prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Jul 22, 2024
1 parent b51329e commit eee725b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
DEBUG = False
DEBUG_TOOLBAR = False

# Export prometheus metrics
PROMETHEUS_METRICS = False

# Notification admins
ADMINS = ()

Expand Down Expand Up @@ -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:
5 changes: 5 additions & 0 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
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
Expand Down

0 comments on commit eee725b

Please sign in to comment.