From 9746c85bb0fb64cf9f61e8794c0ddee9f9628c16 Mon Sep 17 00:00:00 2001 From: Pierros Papadeas Date: Mon, 4 Mar 2019 14:06:42 +0200 Subject: [PATCH] Replace raven with sentry-sdk --- env-dist | 4 ++++ network/settings.py | 51 +++++++++++--------------------------------- requirements-dev.txt | 17 +++++++-------- requirements.txt | 23 ++++++++++---------- setup.cfg | 4 +--- 5 files changed, 36 insertions(+), 63 deletions(-) diff --git a/env-dist b/env-dist index fb7948d..7fd1886 100644 --- a/env-dist +++ b/env-dist @@ -10,3 +10,7 @@ # Mapbox # MAPBOX_TOKEN=enter_mapbox_token_here + +# Sentry +# SENTRY_ENABLED=False +# SENTRY_DSN='sentry_dsn' diff --git a/network/settings.py b/network/settings.py index adc3c44..25c48f7 100644 --- a/network/settings.py +++ b/network/settings.py @@ -1,8 +1,8 @@ from decouple import config, Csv from dj_database_url import parse as db_url from unipath import Path -import os -import raven +import sentry_sdk +from sentry_sdk.integrations.django import DjangoIntegration ROOT = Path(__file__).parent @@ -33,7 +33,6 @@ THIRD_PARTY_APPS = ( 'allauth.socialaccount', 'compressor', 'csp', - 'raven.contrib.django.raven_compat', ) LOCAL_APPS = ( 'network.users', @@ -191,11 +190,7 @@ AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify' # Logging LOGGING = { 'version': 1, - 'disable_existing_loggers': True, - 'root': { - 'level': 'WARNING', - 'handlers': ['sentry'], - }, + 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s - %(process)d %(thread)d - %(message)s' @@ -207,11 +202,6 @@ LOGGING = { } }, 'handlers': { - 'sentry': { - 'level': 'ERROR', - 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', - 'tags': {'custom-tag': 'x'}, - }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', @@ -220,9 +210,9 @@ LOGGING = { }, 'loggers': { 'django.request': { - 'handlers': ['console'], 'level': 'ERROR', - 'propagate': True, + 'handlers': ['console'], + 'propagate': False, }, 'django.network.backends': { 'level': 'ERROR', @@ -234,33 +224,16 @@ LOGGING = { 'handlers': ['console'], 'propagate': False, }, - 'django.db.backends': { - 'level': 'ERROR', - 'handlers': ['console'], - 'propagate': False, - }, - 'raven': { - 'level': 'DEBUG', - 'handlers': ['console'], - 'propagate': False, - }, - 'sentry.errors': { - 'level': 'DEBUG', - 'handlers': ['console'], - 'propagate': False, - }, } } -# Raven - Sentry -RAVEN_ENABLED = config('RAVEN_ENABLED', default=False) -if RAVEN_ENABLED: - RAVEN_CONFIG = { - 'dsn': config('RAVEN_DSN', default=''), - 'release': raven.fetch_git_sha(os.path.abspath(os.curdir)), - } -else: - RAVEN_CONFIG = {} +# Sentry +SENTRY_ENABLED = config('SENTRY_ENABLED', default=False, cast=bool) +if SENTRY_ENABLED: + sentry_sdk.init( + dsn=config('SENTRY_DSN', default=''), + integrations=[DjangoIntegration()] + ) # Celery CELERY_ENABLE_UTC = USE_TZ diff --git a/requirements-dev.txt b/requirements-dev.txt index ea100da..c203877 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,10 +5,9 @@ -r requirements.txt apipkg==1.5 -atomicwrites==1.2.1 -attrs==18.2.0 +atomicwrites==1.3.0 +attrs==19.1.0 coverage==4.5.2 -docopts==0.6.1 execnet==1.5.0 factory-boy==2.11.1 Faker==0.8.18 @@ -17,15 +16,15 @@ ipaddress==1.0.22 mock==2.0.0 more-itertools==5.0.0 pathlib2==2.3.3 -pbr==5.1.1 -pluggy==0.8.1 +pbr==5.1.3 +pluggy==0.9.0 pur==5.2.1 -py==1.7.0 -pytest==4.1.1 +py==1.8.0 +pytest==4.3.0 pytest-cov==2.6.1 -pytest-django==3.4.5 +pytest-django==3.4.8 pytest-forked==0.2 pytest-xdist==1.25.0 -python-dateutil==2.7.5 +python-dateutil==2.8.0 scandir==1.9.0 text-unidecode==1.2 diff --git a/requirements.txt b/requirements.txt index 3634847..e758044 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ # Please edit 'setup.cfg' to add top-level dependencies and use # './contrib/refresh-requirements.sh to regenerate this file -amqp==2.4.0 +amqp==2.4.2 args==0.1.0 backports.csv==1.0.6 billiard==3.5.0.5 @@ -14,10 +14,10 @@ Click==7.0 clint==0.5.1 contextlib2==0.5.5 dj-database-url==0.5.0 -Django==1.11.18 +Django==1.11.20 django-allauth==0.35.0 -django-appconf==1.0.2 -django-autoslug==1.9.3 +django-appconf==1.0.3 +django-autoslug==1.9.4 django-avatar==4.1.0 django-braces==1.12.0 django-compressor==2.2 @@ -28,17 +28,17 @@ django-jsonfield==1.0.1 django-redis-cache==1.7.1 django-shortuuidfield==0.1.3 djangorestframework==3.7.7 -docopt==0.6.1 +docopt==0.6.2 gunicorn==19.7.1 idna==2.8 internetarchive==1.7.7 jsonpatch==1.23 jsonpointer==2.0 -kombu==4.2.2.post1 -lxml==4.3.0 +kombu==4.4.0 +lxml==4.3.2 Markdown==2.6.11 mysqlclient==1.3.14 -oauthlib==3.0.0 +oauthlib==3.0.1 orbit@git+https://gitlab.com/librespacefoundation/orbit.git@db463c2d261365485c157f2c86233aaf44e577a2 Pillow==5.0.0 pyephem==3.7.6.0 @@ -47,19 +47,18 @@ python-decouple==3.1 python-dotenv==0.6.5 python-openid==2.2.5 pytz==2018.9 -raven==6.9.0 rcssmin==1.0.6 redis==2.10.6 requests==2.21.0 requests-cache==0.4.13 requests-oauthlib==1.2.0 rjsmin==1.0.12 -schema==0.6.8 -sentry-sdk==0.6.9 +schema==0.7.0 +sentry-sdk==0.7.4 shortuuid==0.5.0 six==1.12.0 social-auth-app-django==1.2.0 -social-auth-core==3.0.0 +social-auth-core==3.1.0 unicode-slugify==0.1.3 Unidecode==1.0.23 Unipath==1.1 diff --git a/setup.cfg b/setup.cfg index b67e4e8..f9c63b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,8 +36,7 @@ install_requires = django-redis-cache~=1.7.0 redis<3 # Logging - raven~=6.9.0 - sentry-sdk~=0.6.0 + sentry-sdk~=0.7.0 # Configuration unicode-slugify~=0.1.0 django-autoslug~=1.9.0 @@ -74,7 +73,6 @@ dev = Faker~=0.8.0 factory-boy~=2.11.0 pur~=5.2.0 - docopts~=0.6.0 [flake8] max-complexity = 25