Replace Slack reporting by Sentry reporting

parent ee395fe0
...@@ -78,7 +78,7 @@ build docker image: ...@@ -78,7 +78,7 @@ build docker image:
- echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com - echo $GITLAB_REGISTRY_PASSWORD | docker login --username thaliawww --password-stdin registry.gitlab.com
script: script:
- docker-compose config -q - docker-compose config -q
- docker-compose build --build-arg install_dev_requirements=0 web - docker-compose build --build-arg install_dev_requirements=0 --build-arg source_commit=$(git rev-parse HEAD) web
- docker-compose run --rm web test - docker-compose run --rm web test
- docker tag $DOCKER_LATEST $DOCKER_TAG - docker tag $DOCKER_LATEST $DOCKER_TAG
- docker push $DOCKER_TAG - docker push $DOCKER_TAG
......
...@@ -4,6 +4,7 @@ LABEL description="Contains the Thaliawebsite Django application" ...@@ -4,6 +4,7 @@ LABEL description="Contains the Thaliawebsite Django application"
# Arguments # Arguments
ARG install_dev_requirements=1 ARG install_dev_requirements=1
ARG source_commit="unknown"
# Try to keep static operation on top to maximise Docker cache utilisation # Try to keep static operation on top to maximise Docker cache utilisation
...@@ -11,6 +12,7 @@ ARG install_dev_requirements=1 ...@@ -11,6 +12,7 @@ ARG install_dev_requirements=1
ENV DJANGO_PRODUCTION 1 ENV DJANGO_PRODUCTION 1
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV SOURCE_COMMIT=${source_commit}
# Set up entrypoint and command # Set up entrypoint and command
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
......
...@@ -16,3 +16,4 @@ pyfcm>=1.4.2,<1.5 ...@@ -16,3 +16,4 @@ pyfcm>=1.4.2,<1.5
celery>=4.0<4.2 celery>=4.0<4.2
redis>=2.10<2.11 redis>=2.10<2.11
django-celery-results>=1.0.1<1.1 django-celery-results>=1.0.1<1.1
raven>=6.4.0,<6.5.0
...@@ -10,14 +10,11 @@ See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ ...@@ -10,14 +10,11 @@ See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
""" """
import os import os
from copy import deepcopy
from django.utils.log import DEFAULT_LOGGING
from . import settings from . import settings
INSTALLED_APPS = settings.INSTALLED_APPS INSTALLED_APPS = settings.INSTALLED_APPS
INSTALLED_APPS.append('django_slack') INSTALLED_APPS.append('raven.contrib.django.raven_compat')
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.abspath(os.path.join( BASE_DIR = os.path.abspath(os.path.join(
...@@ -135,17 +132,57 @@ X_FRAME_OPTIONS = 'DENY' ...@@ -135,17 +132,57 @@ X_FRAME_OPTIONS = 'DENY'
SECURE_CONTENT_TYPE_NOSNIFF = True SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True SECURE_BROWSER_XSS_FILTER = True
# Slack configuration LOGGING = {
SLACK_TOKEN = os.environ.get('DJANGO_SLACK_TOKEN') 'version': 1,
SLACK_CHANNEL = '#django-errors' 'disable_existing_loggers': True,
SLACK_USERNAME = 'Concrexit' 'filters': {
SLACK_ICON_EMOJI = ':pingu:' 'require_debug_false': {
SLACK_FAIL_SILENTLY = True '()': 'django.utils.log.RequireDebugFalse',
},
LOGGING = deepcopy(DEFAULT_LOGGING) },
LOGGING['handlers']['slack-error'] = { 'root': {
'level': 'ERROR', 'level': 'WARNING',
'class': 'django_slack.log.SlackExceptionHandler', 'handlers': ['sentry'],
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s '
'%(process)d %(thread)d %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
'sentry': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'raven.contrib.django.raven_compat.'
'handlers.SentryHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'INFO',
},
'raven': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'sentry.errors': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
},
}
RAVEN_CONFIG = {
'dsn': os.environ.get('SENTRY_DSN'),
'release': os.environ.get('SOURCE_COMMIT'),
} }
LOGGING['loggers']['django']['handlers'].append('slack-error')
LOGGING['loggers']['django']['handlers'].remove('mail_admins')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment