Permalink
Browse files

Enable Sentry logging in production environments

Sentry is an application error capture and management service. These
changes make it possible to send errors generated in production to
Sentry by setting one environment variable, SENTRY_DSN.
  • Loading branch information...
nickstenning committed Feb 4, 2015
1 parent 1f48174 commit 6bf551c85fc141d1df1280fbe6c7aa5d1d5f1a64
Showing with 23 additions and 0 deletions.
  1. +4 −0 h/config.py
  2. +17 −0 h/sentry.py
  3. +1 −0 production.ini
  4. +1 −0 requirements.txt
View
@@ -40,6 +40,10 @@ def _setup_heroku(settings):
if 'REDISTOGO_URL' in os.environ:
settings['redis.sessions.url'] = os.environ['REDISTOGO_URL'] + '0'
# SENTRY_DSN is set by the Heroku Sentry addon
if 'SENTRY_DSN' in os.environ:
settings['sentry.dsn'] = os.environ['SENTRY_DSN']
def _setup_db(settings):
# Allow overriding the model autocreation/deletion from the environment
View
@@ -0,0 +1,17 @@
from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler
def configure_sentry_logger(dsn):
"""
Configure the Sentry log handler for the provided DSN.
"""
handler = SentryHandler(dsn)
setup_logging(handler)
def includeme(config):
dsn = config.registry.settings.get('sentry.dsn')
if dsn is not None:
configure_sentry_logger(dsn)
View
@@ -35,6 +35,7 @@ mail.default_sender: "Annotation Daemon" <no-reply@localhost>
# Include any deployment-specific pyramid add-ons here
pyramid.includes:
h.accounts
h.sentry
pyramid_basemodel
pyramid_mailer
pyramid_redis_sessions
View
@@ -2,4 +2,5 @@
psycogreen
psycopg2
pyramid_redis_sessions==1.0a2
raven
wsaccel

0 comments on commit 6bf551c

Please sign in to comment.