mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 09:36:52 +03:00
Use sentry for error reporting
This commit is contained in:
parent
b2d0a86344
commit
f40f304457
|
@ -118,8 +118,7 @@ Answer the prompts with your own desired options_. For example::
|
|||
use_whitenoise [y]: n
|
||||
use_celery [n]: y
|
||||
use_mailhog [n]: n
|
||||
use_sentry [n]: y
|
||||
use_newrelic [n]: y
|
||||
use_sentry_for_error_reporting [y]: y
|
||||
use_opbeat [n]: y
|
||||
use_pycharm [n]: y
|
||||
windows [n]: n
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
"use_whitenoise": "y",
|
||||
"use_celery": "n",
|
||||
"use_mailhog": "n",
|
||||
"use_sentry": "n",
|
||||
"use_newrelic": "n",
|
||||
"use_sentry_for_error_reporting": "y",
|
||||
"use_opbeat": "n",
|
||||
"use_pycharm": "n",
|
||||
"windows": "n",
|
||||
|
|
|
@ -39,7 +39,7 @@ use_mailhog [n]
|
|||
for development purposes. It runs a simple SMTP server which catches
|
||||
any message sent to it. Messages are displayed in a web interface which runs at ``http://localhost:8025/`` You need to download the MailHog executable for your operating system, see the 'Developing Locally' docs for instructions.
|
||||
|
||||
use_sentry [n]
|
||||
use_sentry_for_error_reporting [n]
|
||||
Whether to use Sentry_ to log errors from your project.
|
||||
|
||||
windows [n]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
web: gunicorn config.wsgi:application
|
||||
{% if cookiecutter.use_celery == "y" -%}
|
||||
worker: {% if cookiecutter.use_newrelic == "y" %}newrelic-admin run-program {% endif %}celery worker --app={{cookiecutter.project_slug}}.taskapp --loglevel=info
|
||||
worker: celery worker --app={{cookiecutter.project_slug}}.taskapp --loglevel=info
|
||||
{%- endif %}
|
||||
|
|
|
@ -104,7 +104,7 @@ The email server will exit when you exit the Grunt task on the CLI with Ctrl+C.
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if cookiecutter.use_sentry == "y" %}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == "y" %}
|
||||
|
||||
Sentry
|
||||
^^^^^^
|
||||
|
|
|
@ -20,12 +20,8 @@
|
|||
"DJANGO_AWS_SECRET_ACCESS_KEY": "",
|
||||
"DJANGO_AWS_STORAGE_BUCKET_NAME": "",
|
||||
"DJANGO_MAILGUN_SERVER_NAME": "",
|
||||
{% if cookiecutter.use_newrelic == "y" -%}
|
||||
"NEW_RELIC_LICENSE_KEY": "",
|
||||
"NEW_RELIC_APP_NAME": "",
|
||||
{%- endif %}
|
||||
"DJANGO_MAILGUN_API_KEY": ""{% if cookiecutter.use_sentry == "y" -%},
|
||||
"DJANGO_SENTRY_DSN": ""{%- endif %}
|
||||
"DJANGO_MAILGUN_API_KEY": ""{% if cookiecutter.use_sentry_for_error_reporting == "y" -%},
|
||||
"DJANGO_SENTRY_DSN": ""{%- endif %}
|
||||
},
|
||||
"scripts": {
|
||||
"postdeploy": "python manage.py migrate"
|
||||
|
|
|
@ -6,7 +6,7 @@ Production Configurations
|
|||
- Use Amazon's S3 for storing static files and uploaded media
|
||||
- Use mailgun to send emails
|
||||
- Use Redis on Heroku
|
||||
{% if cookiecutter.use_sentry == 'y' %}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
- Use sentry for error logging
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_opbeat == 'y' %}
|
||||
|
@ -17,7 +17,7 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
from boto.s3.connection import OrdinaryCallingFormat
|
||||
from django.utils import six
|
||||
{% if cookiecutter.use_sentry == 'y' %}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
import logging
|
||||
{% endif %}
|
||||
|
||||
|
@ -33,7 +33,8 @@ SECRET_KEY = env('DJANGO_SECRET_KEY')
|
|||
# This ensures that Django will be able to detect a secure connection
|
||||
# properly on Heroku.
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
{%- if cookiecutter.use_sentry == 'y'-%}
|
||||
|
||||
{%- if cookiecutter.use_sentry_for_error_reporting == 'y'-%}
|
||||
# raven sentry client
|
||||
# See https://docs.getsentry.com/hosted/clients/python/integrations/django/
|
||||
INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
||||
|
@ -44,7 +45,7 @@ INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
|
|||
WHITENOISE_MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware', )
|
||||
MIDDLEWARE_CLASSES = WHITENOISE_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||
{% endif %}
|
||||
{%- if cookiecutter.use_sentry == 'y' -%}
|
||||
{%- if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
RAVEN_MIDDLEWARE = ('raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware', )
|
||||
MIDDLEWARE_CLASSES = RAVEN_MIDDLEWARE + MIDDLEWARE_CLASSES
|
||||
{% endif %}
|
||||
|
@ -161,11 +162,6 @@ ANYMAIL = {
|
|||
}
|
||||
EMAIL_BACKEND = "anymail.backends.mailgun.MailgunBackend"
|
||||
|
||||
{% if cookiecutter.use_newrelic == 'y'-%}# NEW RELIC
|
||||
# ------------------------------------------------------------------------------
|
||||
NEW_RELIC_LICENSE_KEY = env('NEW_RELIC_LICENSE_KEY')
|
||||
NEW_RELIC_APP_NAME = env('NEW_RELIC_APP_NAME')
|
||||
{%- endif %}
|
||||
# TEMPLATE CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See:
|
||||
|
@ -195,7 +191,7 @@ CACHES = {
|
|||
}
|
||||
}
|
||||
|
||||
{% if cookiecutter.use_sentry == 'y' %}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' %}
|
||||
# Sentry Configuration
|
||||
SENTRY_DSN = env('DJANGO_SENTRY_DSN')
|
||||
SENTRY_CLIENT = env('DJANGO_SENTRY_CLIENT', default='raven.contrib.django.raven_compat.DjangoClient')
|
||||
|
@ -251,7 +247,7 @@ RAVEN_CONFIG = {
|
|||
'CELERY_LOGLEVEL': env.int('DJANGO_SENTRY_LOG_LEVEL', logging.INFO),
|
||||
'DSN': SENTRY_DSN
|
||||
}
|
||||
{% elif cookiecutter.use_sentry == 'n' %}
|
||||
{% elif cookiecutter.use_sentry_for_error_reporting == 'n' %}
|
||||
# LOGGING CONFIGURATION
|
||||
# ------------------------------------------------------------------------------
|
||||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#logging
|
||||
|
|
|
@ -15,13 +15,8 @@ framework.
|
|||
"""
|
||||
import os
|
||||
|
||||
{% if cookiecutter.use_newrelic == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
import newrelic.agent
|
||||
newrelic.agent.initialize()
|
||||
{%- endif %}
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
|
||||
{%- endif %}
|
||||
|
@ -36,14 +31,10 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
|
|||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
application = get_wsgi_application()
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
application = Sentry(application)
|
||||
{%- endif %}
|
||||
{% if cookiecutter.use_newrelic == 'y' -%}
|
||||
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
|
||||
application = newrelic.agent.WSGIApplicationWrapper(application)
|
||||
{%- endif %}
|
||||
# Apply WSGI middleware here.
|
||||
# from helloworld.wsgi import HelloWorldApplication
|
||||
# application = HelloWorldApplication(application)
|
||||
|
|
|
@ -12,13 +12,9 @@ DJANGO_MAILGUN_API_KEY=
|
|||
DJANGO_SERVER_EMAIL=
|
||||
DJANGO_SECURE_SSL_REDIRECT=False
|
||||
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
DJANGO_SENTRY_DSN=
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_newrelic == 'y' -%}
|
||||
NEW_RELIC_LICENSE_KEY=
|
||||
NEW_RELIC_APP_NAME={{cookiecutter.project_slug}}
|
||||
{% endif %}
|
||||
{% if cookiecutter.use_opbeat == 'y' -%}
|
||||
DJANGO_OPBEAT_ORGANIZATION_ID
|
||||
DJANGO_OPBEAT_APP_ID
|
||||
|
|
|
@ -26,18 +26,12 @@ Collectfast==0.2.3
|
|||
# -------------------------------------------------------
|
||||
django-anymail==0.3.1
|
||||
|
||||
{% if cookiecutter.use_sentry == "y" -%}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == "y" -%}
|
||||
# Raven is the Sentry client
|
||||
# --------------------------
|
||||
raven
|
||||
{%- endif %}
|
||||
|
||||
{% if cookiecutter.use_newrelic == "y" -%}
|
||||
# Newrelic agent for performance monitoring
|
||||
# -----------------------------------------
|
||||
newrelic
|
||||
{%- endif %}
|
||||
|
||||
{% if cookiecutter.use_opbeat == "y" -%}
|
||||
# Opbeat agent for performance monitoring
|
||||
# -----------------------------------------
|
||||
|
|
|
@ -24,7 +24,7 @@ class CeleryConfig(AppConfig):
|
|||
app.config_from_object('django.conf:settings')
|
||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)
|
||||
|
||||
{% if cookiecutter.use_sentry == 'y' -%}
|
||||
{% if cookiecutter.use_sentry_for_error_reporting == 'y' -%}
|
||||
if hasattr(settings, 'RAVEN_CONFIG'):
|
||||
# Celery signal registration
|
||||
from raven import Client as RavenClient
|
||||
|
|
Loading…
Reference in New Issue
Block a user