Merge branch '20-sentry' into 'master'

Resolve "Sentry Error Tracking"

Closes #20

See merge request BeryJu.org/passbook!4
This commit is contained in:
Jens Langhammer 2019-03-03 19:58:18 +00:00
commit cbbbb5dc08
3 changed files with 25 additions and 14 deletions

View File

@ -5,9 +5,8 @@ import os
import celery
from django.conf import settings
# from raven import Client
# from raven.contrib.celery import register_logger_signal, register_signal
from raven import Client
from raven.contrib.celery import register_logger_signal, register_signal
# set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passbook.core.settings")
@ -18,16 +17,17 @@ LOGGER = logging.getLogger(__name__)
class Celery(celery.Celery):
"""Custom Celery class with Raven configured"""
# def on_configure(self):
# """Update raven client"""
# try:
# client = Client(settings.RAVEN_CONFIG.get('dsn'))
# # register a custom filter to filter out duplicate logs
# register_logger_signal(client)
# # hook into the Celery error handler
# register_signal(client)
# except RecursionError: # This error happens when pdoc is running
# pass
# pylint: disable=method-hidden
def on_configure(self):
"""Update raven client"""
try:
client = Client(settings.RAVEN_CONFIG.get('dsn'))
# register a custom filter to filter out duplicate logs
register_logger_signal(client)
# hook into the Celery error handler
register_signal(client)
except RecursionError: # This error happens when pdoc is running
pass
# pylint: disable=unused-argument

View File

@ -62,6 +62,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'rest_framework',
'drf_yasg',
'raven.contrib.django.raven_compat',
'passbook.core.apps.PassbookCoreConfig',
'passbook.admin.apps.PassbookAdminConfig',
'passbook.api.apps.PassbookAPIConfig',
@ -104,6 +105,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',
]
ROOT_URLCONF = 'passbook.core.urls'
@ -184,6 +186,14 @@ CELERY_TASK_DEFAULT_QUEUE = 'passbook'
CELERY_BROKER_URL = 'redis://%s' % CONFIG.get('redis')
CELERY_RESULT_BACKEND = 'redis://%s' % CONFIG.get('redis')
# Raven settings
RAVEN_CONFIG = {
'dsn': ('https://55b5dd780bc14f4c96bba69b7a9abbcc:449af483bd0745'
'0d83be640d834e5458@sentry.services.beryju.org/8'),
'release': VERSION,
'environment': 'dev' if DEBUG else 'production',
}
# CherryPY settings
with CONFIG.cd('web'):
CHERRYPY_SERVER = {

View File

@ -10,7 +10,8 @@ https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
import os
from django.core.wsgi import get_wsgi_application
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'passbook.settings')
application = get_wsgi_application()
application = Sentry(get_wsgi_application())