0001-misc-enable-sentry-43116.patch
wcs/publisher.py | ||
---|---|---|
33 | 33 |
except ImportError: |
34 | 34 |
pass |
35 | 35 | |
36 |
try: |
|
37 |
import sentry_sdk |
|
38 |
except ImportError: |
|
39 |
sentry_sdk = None |
|
40 | ||
41 | ||
36 | 42 |
from wcs.qommon import force_str |
37 | 43 |
from .qommon.publisher import set_publisher_class, QommonPublisher, get_request |
38 | 44 | |
... | ... | |
330 | 336 |
exc_type, exc_value, |
331 | 337 |
tb)) |
332 | 338 | |
339 |
self.notify_sentry(exc_tuple, request=self.get_request(), context=context) |
|
340 | ||
333 | 341 |
self.log_internal_error(error_summary, plain_error_msg, record=True) |
334 | 342 | |
335 | 343 |
def log_internal_error(self, error_summary, plain_error_msg, record=False): |
... | ... | |
349 | 357 |
# this could happen on file descriptor exhaustion |
350 | 358 |
pass |
351 | 359 | |
360 |
def can_sentry(self): |
|
361 |
return (sentry_sdk is not None) |
|
362 | ||
363 |
def notify_sentry(self, exc_tuple, request=None, context=None): |
|
364 |
if not self.can_sentry(): |
|
365 |
return |
|
366 | ||
367 |
extra = {} |
|
368 |
tags = {} |
|
369 |
if context: |
|
370 |
extra['context'] = context |
|
371 |
if request: |
|
372 |
extra['request'] = request.dump() |
|
373 |
tags['url'] = request.get_url() |
|
374 | ||
375 |
sentry_sdk.capture_exception(exc_tuple, extra=extra, tags=tags) |
|
376 | ||
352 | 377 |
def apply_global_action_timeouts(self): |
353 | 378 |
from wcs.workflows import Workflow, WorkflowGlobalActionTimeoutTrigger |
354 | 379 |
for workflow in Workflow.select(): |
wcs/qommon/admin/settings.py | ||
---|---|---|
112 | 112 |
(str('html'), _('Display as HTML')) ]) |
113 | 113 |
form.add(CheckboxWidget, 'logger', title=_('Logger'), |
114 | 114 |
value=debug_cfg.get('logger', True)) |
115 |
if get_publisher().can_sentry(): |
|
116 |
form.add( |
|
117 |
StringWidget, 'sentry_dsn', title=_('Sentry DSN'), |
|
118 |
value=debug_cfg.get('sentry_dsn', '')) |
|
115 | 119 |
form.add(CheckboxWidget, 'debug_mode', title = _('Enable debug mode'), |
116 | 120 |
value = debug_cfg.get('debug_mode', False)) |
117 | 121 |
form.add(StringWidget, 'mail_redirection', title = _('Mail redirection'), |
... | ... | |
133 | 137 |
else: |
134 | 138 |
cfg_submit(form, 'debug', ('error_email', 'display_exceptions', |
135 | 139 |
'logger', 'debug_mode', |
136 |
'mail_redirection')) |
|
140 |
'mail_redirection', 'sentry_dsn'))
|
|
137 | 141 |
return redirect('.') |
wcs/qommon/publisher.py | ||
---|---|---|
264 | 264 | |
265 | 265 |
(exc_type, exc_value, tb) = sys.exc_info() |
266 | 266 | |
267 |
self.notify_sentry((exc_type, exc_value, tb), request) |
|
268 | ||
267 | 269 |
if exc_type is NotImplementedError: |
268 | 270 |
get_response().set_header('Content-Type', 'text/html') # set back content-type |
269 | 271 |
return template.error_page( |
270 |
- |