From 89d7dacf3337fed0685aad4409e86b3e137246ad Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 2 Sep 2021 21:15:31 +0000 Subject: Add Django Prometheus to installed apps and middleware --- pydis_site/settings.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'pydis_site') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 7df7ad85..61f3b6f8 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -23,7 +23,8 @@ from pydis_site.constants import GIT_SHA env = environ.Env( DEBUG=(bool, False), - SITE_DSN=(str, "") + SITE_DSN=(str, ""), + BUILDING_DOCKER=(bool, False) ) sentry_sdk.init( @@ -84,10 +85,15 @@ INSTALLED_APPS = [ 'django_filters', 'django_simple_bulma', 'rest_framework', - 'rest_framework.authtoken' + 'rest_framework.authtoken', ] +if not env("BUILDING_DOCKER"): + INSTALLED_APPS.append("django_prometheus") + +# Ensure that Prometheus middlewares are first and last here. MIDDLEWARE = [ + 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'django_hosts.middleware.HostsRequestMiddleware', 'django.middleware.security.SecurityMiddleware', @@ -100,7 +106,9 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django_hosts.middleware.HostsResponseMiddleware', + 'django_prometheus.middleware.PrometheusAfterMiddleware' ] + ROOT_URLCONF = 'pydis_site.urls' TEMPLATES = [ @@ -131,7 +139,7 @@ WSGI_APPLICATION = 'pydis_site.wsgi.application' DATABASES = { 'default': env.db(), - 'metricity': env.db('METRICITY_DB_URL'), + 'metricity': env.db(), } # Password validation -- cgit v1.2.3 From b051c454ac853a145fa961f4409fcadd8b1d5dbc Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 2 Sep 2021 21:15:52 +0000 Subject: Add Django Prometheus to URLs --- pydis_site/apps/home/urls.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pydis_site') diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py index 1e2af8f3..bb77220b 100644 --- a/pydis_site/apps/home/urls.py +++ b/pydis_site/apps/home/urls.py @@ -7,6 +7,7 @@ app_name = 'home' urlpatterns = [ path('', HomeView.as_view(), name='home'), path('', include('pydis_site.apps.redirect.urls')), + path('', include('django_prometheus.urls')), path('admin/', admin.site.urls), path('resources/', include('pydis_site.apps.resources.urls')), path('pages/', include('pydis_site.apps.content.urls')), -- cgit v1.2.3 From 4a6ea09f3849f86d8307526e23362ea93365ebef Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 2 Sep 2021 21:27:54 +0000 Subject: Revert change to Metricity DB URL Co-Authored-By: jchristgit --- pydis_site/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 61f3b6f8..6f49763b 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -139,7 +139,7 @@ WSGI_APPLICATION = 'pydis_site.wsgi.application' DATABASES = { 'default': env.db(), - 'metricity': env.db(), + 'metricity': env.db('METRICITY_DB_URL'), } # Password validation -- cgit v1.2.3