diff --git a/requirements.txt b/requirements.txt index 12d8f24..67b8ef6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,6 @@ django-cors-headers==3.7.0 pytz==2017.2 django-environ==0.4.4 django-filter==2.4.0 -rollbar==0.14.5 +django-prometheus==2.2.0 psycopg2==2.8.5 sentry-sdk==1.12.1 \ No newline at end of file diff --git a/requirements/requirements_dev.txt b/requirements/requirements_dev.txt index 5d05b6d..62b3303 100644 --- a/requirements/requirements_dev.txt +++ b/requirements/requirements_dev.txt @@ -33,7 +33,6 @@ Pygments==2.13.0 python-dateutil==2.6.1 pytz==2017.2 requests==2.20.1 -rollbar==0.14.5 sentry-sdk==1.12.1 six==1.11.0 sqlparse==0.2.4 diff --git a/tafseer_api/settings.py b/tafseer_api/settings.py index 7f041b8..fb00e9e 100644 --- a/tafseer_api/settings.py +++ b/tafseer_api/settings.py @@ -11,7 +11,7 @@ environ.Env.read_env(env_file_path) # reading .env file # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = env('DEBUG') +DEBUG = env.bool('DEBUG') SECRET_KEY = env('SECRET_KEY') @@ -29,6 +29,7 @@ # 3rd party Apps 'rest_framework', 'corsheaders', + 'django_prometheus', # Internal Apps 'quran_text', 'quran_tafseer', @@ -40,6 +41,7 @@ POST_MIDDLEWARE = env.list('POST_MIDDLEWARE', default=[]) MIDDLEWARE = PRE_MIDDLEWARE + [ + 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', @@ -49,7 +51,7 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'rollbar.contrib.django.middleware.RollbarNotifierMiddleware', + 'django_prometheus.middleware.PrometheusAfterMiddleware', ] + POST_MIDDLEWARE ROOT_URLCONF = 'tafseer_api.urls' @@ -136,19 +138,20 @@ # Sentry -sentry_dsn = env('SENTRY_DSN') -sentry_sdk.init( - dsn=sentry_dsn, - integrations=[ - DjangoIntegration(), - ], - - # Set traces_sample_rate to 1.0 to capture 100% - # of transactions for performance monitoring. - # We recommend adjusting this value in production. - traces_sample_rate=1.0, - - # If you wish to associate users to errors (assuming you are using - # django.contrib.auth) you may enable sending PII data. - send_default_pii=True -) \ No newline at end of file +sentry_dsn = env.str('SENTRY_DSN', None) +if sentry_dsn is None: + sentry_sdk.init( + dsn=sentry_dsn, + integrations=[ + DjangoIntegration(), + ], + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production. + traces_sample_rate=1.0, + + # If you wish to associate users to errors (assuming you are using + # django.contrib.auth) you may enable sending PII data. + send_default_pii=True + ) \ No newline at end of file diff --git a/tafseer_api/urls.py b/tafseer_api/urls.py index e7b8642..7bd16ec 100644 --- a/tafseer_api/urls.py +++ b/tafseer_api/urls.py @@ -12,6 +12,7 @@ def trigger_error(request): url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url('sentry-debug/', trigger_error), + url('', include('django_prometheus.urls')), ] urlpatterns += i18n_patterns(url(r'^', include('docs.urls')))