Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
added support to @opbeat awesome error tracking and metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Dec 15, 2015
1 parent 170a274 commit 8d57f95
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 21 deletions.
10 changes: 9 additions & 1 deletion etc/openshift_settings.py
Expand Up @@ -24,6 +24,7 @@
LOGGER_FORMAT = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
LOGGER_DATE_FORMAT = '%d.%m %H:%M:%S'

DEBUG = False
if os.environ['OPENSHIFT_APP_NAME'] == 'quokkadevelopment':
DEBUG_TOOLBAR_ENABLED = True
DEBUG = True
Expand All @@ -33,7 +34,6 @@

MAP_STATIC_ROOT = (
'/robots.txt',
'/sitemap.xml',
'/favicon.ico',
'/vaddy-c603c78bbeba8d9.html'
)
Expand All @@ -51,3 +51,11 @@
"</li>"
"</ul>"
)

OPBEAT = {
'ORGANIZATION_ID': '87883697e9f64e85b1a8170ff664890a',
'APP_ID': 'd924873719',
'SECRET_TOKEN': 'a0fee12cdb9eca36320b42d2d50f57ceea260dc5',
'INCLUDE_PATHS': ['quokka'],
'DEBUG': DEBUG,
}
16 changes: 2 additions & 14 deletions quokka/ext/__init__.py
Expand Up @@ -7,7 +7,7 @@

from . import (generic, babel, blueprints, error_handlers, context_processors,
template_filters, before_request, views, themes, fixtures,
oauthlib, weasyprint, security)
oauthlib, weasyprint, security, development)


def configure_extensions(app, admin):
Expand All @@ -26,22 +26,10 @@ def configure_extensions(app, admin):
blueprints.load_from_folder(app)
weasyprint.configure(app)
configure_admin(app, admin)

if app.config.get('DEBUG_TOOLBAR_ENABLED'):
try:
from flask_debugtoolbar import DebugToolbarExtension
DebugToolbarExtension(app)
except:
app.logger.info('flask_debugtoolbar is not installed')

development.configure(app, admin)
before_request.configure(app)
views.configure(app)
oauthlib.configure(app)

if app.config.get('SENTRY_ENABLED', False):
from .sentry import configure
configure(app)

return app


Expand Down
28 changes: 28 additions & 0 deletions quokka/ext/development.py
@@ -0,0 +1,28 @@
# coding: utf-8


def configure(app, admin=None):
if app.config.get('DEBUG_TOOLBAR_ENABLED'):
try:
from flask_debugtoolbar import DebugToolbarExtension
DebugToolbarExtension(app)
except ImportError:
app.logger.info('flask_debugtoolbar is not installed')

if app.config.get('OPBEAT'):
try:
from opbeat.contrib.flask import Opbeat
Opbeat(
app,
logging=app.config.get('OPBEAT', {}).get('LOGGING', False)
)
app.logger.info('opbeat configured!!!')
except ImportError:
app.logger.info('opbeat is not installed')

if app.config.get('SENTRY_ENABLED', False):
try:
from raven.contrib.flask import Sentry
app.sentry = Sentry(app)
except ImportError:
app.logger.info('sentry, raven is not installed')
6 changes: 0 additions & 6 deletions quokka/ext/sentry.py

This file was deleted.

25 changes: 25 additions & 0 deletions quokka/settings.py
Expand Up @@ -326,3 +326,28 @@
HTTP method (such as PATCH).
"""
HTTP_PROXY_METHOD_OVERRIDE = False


"""
https://opbeat.com is application monitoring tool
you can enable it but you need to install requirements/dev.txt
https://opbeat.com/docs/articles/get-started-with-flask/
OPBEAT = {
'ORGANIZATION_ID': '<ORGANIZATION-ID>',
'APP_ID': '<APP-ID>',
'SECRET_TOKEN': '<SECRET-TOKEN>',
'INCLUDE_PATHS': ['quokka'],
'DEBUG': True,
'LOGGING': False
}
Notify Opbeat when a release has completed
$ curl https://intake.opbeat.com/api/v1/
organizations/<ORGANIZATION-ID>/apps/<APP-ID>/releases/ \
-H "Authorization: Bearer <SECRET-TOKEN>" \
-d rev=`git log -n 1 --pretty=format:%H` \
-d branch=`git rev-parse --abbrev-ref HEAD` \
-d status=completed
"""
# OPBEAT = None
1 change: 1 addition & 0 deletions requirements/dev.txt
@@ -1,3 +1,4 @@
Flask-DebugToolbar==0.10.0
ipython==4.0.1
ipdb==0.8.1
opbeat==3.1.3

0 comments on commit 8d57f95

Please sign in to comment.