0001-misc-remove-support-for-sentry-35913.patch
help/fr/settings-env.page | ||
---|---|---|
32 | 32 |
</p> |
33 | 33 |
</section> |
34 | 34 | |
35 |
<section> |
|
36 |
<title>Accès au serveur Sentry</title> |
|
37 | ||
38 |
<p> |
|
39 |
Également accessible depuis l'écran de paramétrage des options de debug, l'adresse (DSN) du serveur Sentry, pour la notification des erreurs |
|
40 |
applicatives, peut aussi être placée dans la variable d'environnement |
|
41 |
<code>SENTRY_DSN</code>. |
|
42 |
</p> |
|
43 |
</section> |
|
44 | ||
45 | 35 |
<section> |
46 | 36 |
<title>Fréquence de vérification des expirations des sauts</title> |
47 | 37 |
wcs/qommon/admin/settings.py | ||
---|---|---|
111 | 111 |
(str('html'), _('Display as HTML')) ]) |
112 | 112 |
form.add(CheckboxWidget, 'logger', title=_('Logger'), |
113 | 113 |
value=debug_cfg.get('logger', True)) |
114 |
if get_publisher().can_sentry(): |
|
115 |
form.add(StringWidget, 'sentry_dsn', title=_('Sentry DSN'), |
|
116 |
value=debug_cfg.get('sentry_dsn', '')) |
|
117 |
else: |
|
118 |
form.add_hidden('sentry_dsn', debug_cfg.get('sentry_dsn', '')) |
|
119 | 114 |
form.add(CheckboxWidget, 'debug_mode', title = _('Enable debug mode'), |
120 | 115 |
value = debug_cfg.get('debug_mode', False)) |
121 | 116 |
form.add(StringWidget, 'mail_redirection', title = _('Mail redirection'), |
... | ... | |
137 | 132 |
else: |
138 | 133 |
cfg_submit(form, 'debug', ('error_email', 'display_exceptions', |
139 | 134 |
'logger', 'debug_mode', |
140 |
'mail_redirection', 'sentry_dsn'))
|
|
135 |
'mail_redirection')) |
|
141 | 136 |
return redirect('.') |
wcs/qommon/publisher.py | ||
---|---|---|
40 | 40 |
from StringIO import StringIO |
41 | 41 |
import xml.etree.ElementTree as ET |
42 | 42 | |
43 |
try: |
|
44 |
import raven |
|
45 |
except ImportError: |
|
46 |
raven = None |
|
47 | ||
48 | 43 |
from django.conf import settings |
49 | 44 |
from django.http import Http404 |
50 | 45 |
from django.utils import translation |
... | ... | |
262 | 257 |
exc_type, exc_value, |
263 | 258 |
tb)) |
264 | 259 | |
265 |
self.notify_sentry(exc_tuple, request=self.get_request(), |
|
266 |
context=context) |
|
267 | ||
268 | 260 |
self.log_internal_error(error_summary, plain_error_msg, record=True) |
269 | 261 | |
270 | 262 |
def log_internal_error(self, error_summary, plain_error_msg, record=False): |
... | ... | |
278 | 270 |
# this could happen on file descriptor exhaustion |
279 | 271 |
pass |
280 | 272 | |
281 |
def can_sentry(self): |
|
282 |
return (raven is not None) |
|
283 | ||
284 |
def notify_sentry(self, exc_tuple, request=None, context=None): |
|
285 |
if not self.can_sentry(): |
|
286 |
return |
|
287 | ||
288 |
debug_cfg = self.cfg.get('debug', {}) |
|
289 |
sentry_dsn = debug_cfg.get('sentry_dsn') or os.environ.get('SENTRY_DSN') |
|
290 |
if not sentry_dsn: |
|
291 |
return |
|
292 | ||
293 |
from raven.transport.requests import RequestsHTTPTransport |
|
294 |
client = raven.Client(sentry_dsn, transport=RequestsHTTPTransport) |
|
295 |
extra = {} |
|
296 |
tags = {} |
|
297 |
if context: |
|
298 |
extra['context'] = context |
|
299 |
if request: |
|
300 |
extra['request'] = request.dump() |
|
301 |
tags['url'] = request.get_url() |
|
302 | ||
303 |
client.captureException(exc_tuple, extra=extra, tags=tags) |
|
304 | ||
305 | 273 |
def finish_successful_request(self): |
306 | 274 |
if not self.get_request().ignore_session: |
307 | 275 |
self.session_manager.finish_successful_request() |
... | ... | |
318 | 286 | |
319 | 287 |
(exc_type, exc_value, tb) = sys.exc_info() |
320 | 288 | |
321 |
self.notify_sentry((exc_type, exc_value, tb), request) |
|
322 | ||
323 | 289 |
if exc_type is NotImplementedError: |
324 | 290 |
get_response().set_header('Content-Type', 'text/html') # set back content-type |
325 | 291 |
return template.error_page( |
326 |
- |