Skip to content

Commit

Permalink
Merge pull request #25 from diggyk/master
Browse files Browse the repository at this point in the history
Added Sentry support
  • Loading branch information
gmjosack committed Jul 17, 2015
2 parents dfdad2a + 1c608cf commit bea8f8f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
20 changes: 20 additions & 0 deletions bin/hermes-server
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ from hermes.settings import settings

from sqlalchemy.exc import OperationalError

try:
from raven.contrib.tornado import AsyncSentryClient
raven_installed = True
except ImportError:
raven_installed = False

sa_log = logging.getLogger("sqlalchemy.engine.base.Engine")


Expand Down Expand Up @@ -72,6 +78,20 @@ def main():

application = Application(my_settings=my_settings, **tornado_settings)

# If Sentry DSN is set, try to import raven
if settings.sentry_dsn:
if not raven_installed:
logging.warning(
'Sentry DSN set but raven not installed. Not enabling Sentry.'
)
else:
logging.info(
'Sentry DSN set and raven installed. Enabling Sentry.'
)
application.sentry_client = AsyncSentryClient(settings.sentry_dsn)
else:
logging.info('Sentry DSN not set. Not enabling Sentry.')

port = args.port or settings.port

logging.info(
Expand Down
3 changes: 3 additions & 0 deletions config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ email_notifications: false
# This is the expiration (in seconds) of auth_tokens used for API calls
# Type: int
auth_token_expiry: 600

# Sentry DSN if using Sentry to log exceptions.
# sentry_dsn:
11 changes: 11 additions & 0 deletions hermes/handlers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
# Logging object
log = logging.getLogger(__name__)

# If raven library is available, modify the base handler to support Sentry.
try:
from raven.contrib.tornado import SentryMixin
except ImportError:
pass
else:
class SentryHandler(SentryMixin, RequestHandler):
pass
RequestHandler = SentryHandler



class PluginHelper(object):
@classmethod
Expand Down
1 change: 1 addition & 0 deletions hermes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ def __getattr__(self, name):
"api_xsrf_enabled": True,
"secret_key": "SECRET_KEY",
"auth_token_expiry": 600, # 10 minutes
"sentry_dsn": None,
})
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.1"
__version__ = "0.2.2"

0 comments on commit bea8f8f

Please sign in to comment.