Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #69 from AusDTO/rollbar
Browse files Browse the repository at this point in the history
Add rollbar integration
  • Loading branch information
maxious authored Dec 4, 2016
2 parents 73d4529 + ce7dfdf commit 900083f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dmutils/flask_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jinja2

import flask_featureflags
from . import config, logging, force_https, request_id, formats, filters
from . import config, logging, force_https, request_id, formats, filters, rollbar_agent
from flask import Markup, redirect, request, session, current_app, abort
from flask.ext.script import Manager, Server
from flask_login import current_user
Expand Down Expand Up @@ -40,6 +40,7 @@ def init_app(
ProxyFix(application)
request_id.init_app(application)
force_https.init_app(application)
rollbar_agent.init_app(application)

flask_featureflags.FeatureFlag(application)

Expand Down
20 changes: 20 additions & 0 deletions dmutils/rollbar_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import rollbar
import rollbar.contrib.flask
from flask import got_request_exception


def init_app(app):
if app.config.get('ROLLBAR_TOKEN'):
rollbar.init(
# access token for the demo app: https://rollbar.com/demo
app.config['ROLLBAR_TOKEN'],
# environment name
app.config['DM_ENVIRONMENT'],
# server root directory, makes tracebacks prettier
root=os.path.dirname(os.path.realpath(__file__)),
# flask already sets up logging
allow_logging_basic_config=False)

# send exceptions from `app` to rollbar, using flask's signal system.
got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
2 changes: 2 additions & 0 deletions requirements_for_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ cffi
tox
flake8
responses
blinker
rollbar

0 comments on commit 900083f

Please sign in to comment.