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

View File

@ -62,6 +62,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'rest_framework', 'rest_framework',
'drf_yasg', 'drf_yasg',
'raven.contrib.django.raven_compat',
'passbook.core.apps.PassbookCoreConfig', 'passbook.core.apps.PassbookCoreConfig',
'passbook.admin.apps.PassbookAdminConfig', 'passbook.admin.apps.PassbookAdminConfig',
'passbook.api.apps.PassbookAPIConfig', 'passbook.api.apps.PassbookAPIConfig',
@ -104,6 +105,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',
] ]
ROOT_URLCONF = 'passbook.core.urls' ROOT_URLCONF = 'passbook.core.urls'
@ -184,6 +186,14 @@ CELERY_TASK_DEFAULT_QUEUE = 'passbook'
CELERY_BROKER_URL = 'redis://%s' % CONFIG.get('redis') CELERY_BROKER_URL = 'redis://%s' % CONFIG.get('redis')
CELERY_RESULT_BACKEND = '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 # CherryPY settings
with CONFIG.cd('web'): with CONFIG.cd('web'):
CHERRYPY_SERVER = { CHERRYPY_SERVER = {

View File

@ -10,7 +10,8 @@ https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
import os import os
from django.core.wsgi import get_wsgi_application 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') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'passbook.settings')
application = get_wsgi_application() application = Sentry(get_wsgi_application())