Mercurial > kallithea
annotate rhodecode/lib/middleware/sentry.py @ 3169:a649599ad8b7 beta
added my gist script for another detailed installation instructions
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 18 Jan 2013 01:11:28 +0100 |
parents | 9937afa7f093 |
children | ffd45b185016 |
rev | line source |
---|---|
2939
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.lib.middleware.sentry |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 middleware to handle sentry/raven publishing of errors |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: September 18, 2012 |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # (at your option) any later version. |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 try: |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 from raven.base import Client |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 from raven.contrib.pylons import list_from_setting |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 from raven.middleware import Sentry as Middleware |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 except ImportError: |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 Sentry = None |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 else: |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 class Sentry(Middleware): |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 def __init__(self, app, config, client_cls=Client): |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 client = client_cls( |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 dsn=config.get('sentry.dsn'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 servers=list_from_setting(config, 'sentry.servers'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 name=config.get('sentry.name'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 key=config.get('sentry.key'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 public_key=config.get('sentry.public_key'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 secret_key=config.get('sentry.secret_key'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 project=config.get('sentry.project'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 site=config.get('sentry.site'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 include_paths=list_from_setting(config, 'sentry.include_paths'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 exclude_paths=list_from_setting(config, 'sentry.exclude_paths'), |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 ) |
2973
9937afa7f093
whitespace cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2939
diff
changeset
|
47 super(Sentry, self).__init__(app, client) |