changeset 2939:dbe3cfb81446 beta

Added Errormator and Sentry support part of pull request #71
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 18 Oct 2012 23:54:46 +0200
parents 0497d9d9e0c8
children 606ea96a982b
files development.ini production.ini rhodecode/config/deployment.ini_tmpl rhodecode/config/middleware.py rhodecode/lib/middleware/errormator.py rhodecode/lib/middleware/sentry.py
diffstat 6 files changed, 400 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Tue Oct 16 11:39:47 2012 +0800
+++ b/development.ini	Thu Oct 18 23:54:46 2012 +0200
@@ -227,6 +227,111 @@
 #beaker.session.cookie_expires = 3600
 
 
+############################
+## ERROR HANDLING SYSTEMS ##
+############################
+
+####################
+### [errormator] ###
+####################
+
+# Errormator is tailored to work with RhodeCode, see 
+# http://errormator.com for details how to obtain an account
+# you must install python package `errormator_client` to make it work
+
+# errormator enabled
+errormator = true
+
+errormator.server_url = https://api.errormator.com
+errormator.api_key = YOUR_API_KEY
+
+# TWEAK AMOUNT OF INFO SENT HERE
+
+# enables 404 error logging (default False)
+errormator.report_404 = false
+
+# time in seconds after request is considered being slow (default 1)
+errormator.slow_request_time = 1
+
+# record slow requests in application
+# (needs to be enabled for slow datastore recording and time tracking)
+errormator.slow_requests = true
+
+# enable hooking to application loggers
+# errormator.logging = true
+
+# minimum log level for log capture
+# errormator.logging.level = WARNING
+
+# send logs only from erroneous/slow requests
+# (saves API quota for intensive logging)
+errormator.logging_on_error = false
+
+# list of additonal keywords that should be grabbed from environ object 
+# can be string with comma separated list of words in lowercase
+# (by default client will always send following info:
+# 'REMOTE_USER', 'REMOTE_ADDR', 'SERVER_NAME', 'CONTENT_TYPE' + all keys that 
+# start with HTTP* this list be extended with additional keywords here
+errormator.environ_keys_whitelist = 
+
+
+# list of keywords that should be blanked from request object 
+# can be string with comma separated list of words in lowercase
+# (by default client will always blank keys that contain following words 
+# 'password', 'passwd', 'pwd', 'auth_tkt', 'secret', 'csrf'
+# this list be extended with additional keywords set here
+errormator.request_keys_blacklist =
+
+
+# list of namespaces that should be ignores when gathering log entries
+# can be string with comma separated list of namespaces
+# (by default the client ignores own entries: errormator_client.client)
+errormator.log_namespace_blacklist =  
+
+#
+# YOU SHOULD NOT NEED TO TWEAK THIS
+#
+
+# leave server_name empty for auto discovery
+# errormator.server_name =
+
+# connection timeout when communicating with API
+# errormator.timeout = 10
+
+# reraise exceptions when wsgi catches exception
+# errormator.reraise_exceptions = true
+
+# enables 500 error logging
+errormator.report_errors = true  
+
+# how often send data to mothership Errormator (default 5s)
+errormator.buffer_flush_interval = 5
+
+# send all data after request is finished - handy for crons or other voliatile applications
+errormator.force_send = false
+
+# custom filter callable to override sensitive data filtering
+# errormator.filter_callable = foo.bar.baz:callable_name
+
+################
+### [sentry] ###
+################
+
+# sentry is a alternative open source error aggregator
+# you must install python packages `sentry` and `raven` to enable 
+
+sentry.dsn = YOUR_DNS
+sentry.servers =
+sentry.name =
+sentry.key =
+sentry.public_key =
+sentry.secret_key =
+sentry.project =
+sentry.site =
+sentry.include_paths =
+sentry.exclude_paths =
+
+
 ################################################################################
 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*  ##
 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to  ##
--- a/production.ini	Tue Oct 16 11:39:47 2012 +0800
+++ b/production.ini	Thu Oct 18 23:54:46 2012 +0200
@@ -227,6 +227,111 @@
 #beaker.session.cookie_expires = 3600
 
 
+############################
+## ERROR HANDLING SYSTEMS ##
+############################
+
+####################
+### [errormator] ###
+####################
+
+# Errormator is tailored to work with RhodeCode, see 
+# http://errormator.com for details how to obtain an account
+# you must install python package `errormator_client` to make it work
+
+# errormator enabled
+errormator = true
+
+errormator.server_url = https://api.errormator.com
+errormator.api_key = YOUR_API_KEY
+
+# TWEAK AMOUNT OF INFO SENT HERE
+
+# enables 404 error logging (default False)
+errormator.report_404 = false
+
+# time in seconds after request is considered being slow (default 1)
+errormator.slow_request_time = 1
+
+# record slow requests in application
+# (needs to be enabled for slow datastore recording and time tracking)
+errormator.slow_requests = true
+
+# enable hooking to application loggers
+# errormator.logging = true
+
+# minimum log level for log capture
+# errormator.logging.level = WARNING
+
+# send logs only from erroneous/slow requests
+# (saves API quota for intensive logging)
+errormator.logging_on_error = false
+
+# list of additonal keywords that should be grabbed from environ object 
+# can be string with comma separated list of words in lowercase
+# (by default client will always send following info:
+# 'REMOTE_USER', 'REMOTE_ADDR', 'SERVER_NAME', 'CONTENT_TYPE' + all keys that 
+# start with HTTP* this list be extended with additional keywords here
+errormator.environ_keys_whitelist = 
+
+
+# list of keywords that should be blanked from request object 
+# can be string with comma separated list of words in lowercase
+# (by default client will always blank keys that contain following words 
+# 'password', 'passwd', 'pwd', 'auth_tkt', 'secret', 'csrf'
+# this list be extended with additional keywords set here
+errormator.request_keys_blacklist =
+
+
+# list of namespaces that should be ignores when gathering log entries
+# can be string with comma separated list of namespaces
+# (by default the client ignores own entries: errormator_client.client)
+errormator.log_namespace_blacklist =  
+
+#
+# YOU SHOULD NOT NEED TO TWEAK THIS
+#
+
+# leave server_name empty for auto discovery
+# errormator.server_name =
+
+# connection timeout when communicating with API
+# errormator.timeout = 10
+
+# reraise exceptions when wsgi catches exception
+# errormator.reraise_exceptions = true
+
+# enables 500 error logging
+errormator.report_errors = true  
+
+# how often send data to mothership Errormator (default 5s)
+errormator.buffer_flush_interval = 5
+
+# send all data after request is finished - handy for crons or other voliatile applications
+errormator.force_send = false
+
+# custom filter callable to override sensitive data filtering
+# errormator.filter_callable = foo.bar.baz:callable_name
+
+################
+### [sentry] ###
+################
+
+# sentry is a alternative open source error aggregator
+# you must install python packages `sentry` and `raven` to enable 
+
+sentry.dsn = YOUR_DNS
+sentry.servers =
+sentry.name =
+sentry.key =
+sentry.public_key =
+sentry.secret_key =
+sentry.project =
+sentry.site =
+sentry.include_paths =
+sentry.exclude_paths =
+
+
 ################################################################################
 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*  ##
 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to  ##
--- a/rhodecode/config/deployment.ini_tmpl	Tue Oct 16 11:39:47 2012 +0800
+++ b/rhodecode/config/deployment.ini_tmpl	Thu Oct 18 23:54:46 2012 +0200
@@ -227,6 +227,111 @@
 #beaker.session.cookie_expires = 3600
 
 
+############################
+## ERROR HANDLING SYSTEMS ##
+############################
+
+####################
+### [errormator] ###
+####################
+
+# Errormator is tailored to work with RhodeCode, see 
+# http://errormator.com for details how to obtain an account
+# you must install python package `errormator_client` to make it work
+
+# errormator enabled
+errormator = true
+
+errormator.server_url = https://api.errormator.com
+errormator.api_key = YOUR_API_KEY
+
+# TWEAK AMOUNT OF INFO SENT HERE
+
+# enables 404 error logging (default False)
+errormator.report_404 = false
+
+# time in seconds after request is considered being slow (default 1)
+errormator.slow_request_time = 1
+
+# record slow requests in application
+# (needs to be enabled for slow datastore recording and time tracking)
+errormator.slow_requests = true
+
+# enable hooking to application loggers
+# errormator.logging = true
+
+# minimum log level for log capture
+# errormator.logging.level = WARNING
+
+# send logs only from erroneous/slow requests
+# (saves API quota for intensive logging)
+errormator.logging_on_error = false
+
+# list of additonal keywords that should be grabbed from environ object 
+# can be string with comma separated list of words in lowercase
+# (by default client will always send following info:
+# 'REMOTE_USER', 'REMOTE_ADDR', 'SERVER_NAME', 'CONTENT_TYPE' + all keys that 
+# start with HTTP* this list be extended with additional keywords here
+errormator.environ_keys_whitelist = 
+
+
+# list of keywords that should be blanked from request object 
+# can be string with comma separated list of words in lowercase
+# (by default client will always blank keys that contain following words 
+# 'password', 'passwd', 'pwd', 'auth_tkt', 'secret', 'csrf'
+# this list be extended with additional keywords set here
+errormator.request_keys_blacklist =
+
+
+# list of namespaces that should be ignores when gathering log entries
+# can be string with comma separated list of namespaces
+# (by default the client ignores own entries: errormator_client.client)
+errormator.log_namespace_blacklist =  
+
+#
+# YOU SHOULD NOT NEED TO TWEAK THIS
+#
+
+# leave server_name empty for auto discovery
+# errormator.server_name =
+
+# connection timeout when communicating with API
+# errormator.timeout = 10
+
+# reraise exceptions when wsgi catches exception
+# errormator.reraise_exceptions = true
+
+# enables 500 error logging
+errormator.report_errors = true  
+
+# how often send data to mothership Errormator (default 5s)
+errormator.buffer_flush_interval = 5
+
+# send all data after request is finished - handy for crons or other voliatile applications
+errormator.force_send = false
+
+# custom filter callable to override sensitive data filtering
+# errormator.filter_callable = foo.bar.baz:callable_name
+
+################
+### [sentry] ###
+################
+
+# sentry is a alternative open source error aggregator
+# you must install python packages `sentry` and `raven` to enable 
+
+sentry.dsn = YOUR_DNS
+sentry.servers =
+sentry.name =
+sentry.key =
+sentry.public_key =
+sentry.secret_key =
+sentry.project =
+sentry.site =
+sentry.include_paths =
+sentry.exclude_paths =
+
+
 ################################################################################
 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*  ##
 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to  ##
--- a/rhodecode/config/middleware.py	Tue Oct 16 11:39:47 2012 +0800
+++ b/rhodecode/config/middleware.py	Thu Oct 18 23:54:46 2012 +0200
@@ -53,6 +53,13 @@
 
     if asbool(full_stack):
 
+        from rhodecode.lib.middleware.sentry import Sentry
+        from rhodecode.lib.middleware.errormator import Errormator
+        if Errormator:
+            app = Errormator(app, config)
+        elif Sentry:
+            app = Sentry(app, config)
+
         # Handle Python exceptions
         app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rhodecode/lib/middleware/errormator.py	Thu Oct 18 23:54:46 2012 +0200
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+"""
+    rhodecode.lib.middleware.errormator
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    middleware to handle errormator publishing of errors
+
+    :created_on: October 18, 2012
+    :author: marcink
+    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
+    :license: GPLv3, see COPYING for more details.
+"""
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+try:
+    from errormator_client import make_errormator_middleware
+except ImportError:
+    Errormator = None
+else:
+    Errormator = make_errormator_middleware
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rhodecode/lib/middleware/sentry.py	Thu Oct 18 23:54:46 2012 +0200
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+"""
+    rhodecode.lib.middleware.sentry
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    middleware to handle sentry/raven publishing of errors
+
+    :created_on: September 18, 2012
+    :author: marcink
+    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
+    :license: GPLv3, see COPYING for more details.
+"""
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+try:
+    from raven.base import Client
+    from raven.contrib.pylons import list_from_setting
+    from raven.middleware import Sentry as Middleware
+except ImportError:
+    Sentry = None
+else:
+    class Sentry(Middleware):
+        def __init__(self, app, config, client_cls=Client):
+            client = client_cls(
+                dsn=config.get('sentry.dsn'),
+                servers=list_from_setting(config, 'sentry.servers'),
+                name=config.get('sentry.name'),
+                key=config.get('sentry.key'),
+                public_key=config.get('sentry.public_key'),
+                secret_key=config.get('sentry.secret_key'),
+                project=config.get('sentry.project'),
+                site=config.get('sentry.site'),
+                include_paths=list_from_setting(config, 'sentry.include_paths'),
+                exclude_paths=list_from_setting(config, 'sentry.exclude_paths'),
+            )
+            super(Sentry, self).__init__(app, client)
\ No newline at end of file