-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from eduNEXT/lmm/ignore_error_sentry
Add capability to ignore exceptions in sentry.
- Loading branch information
Showing
7 changed files
with
61 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
""" | ||
Init for main eox-core app | ||
""" | ||
__version__ = '2.8.1' | ||
__version__ = '2.9.0' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
This file implements utils used for sentry integration. | ||
See: https://github.com/eduNEXT/eox-core#integrations-with-third-party-services | ||
""" | ||
import importlib | ||
|
||
from django.conf import settings | ||
|
||
|
||
def load_class(full_class_string): | ||
""" | ||
dynamically load a class from a string | ||
""" | ||
|
||
class_data = full_class_string.split(".") | ||
module_path = ".".join(class_data[:-1]) | ||
class_str = class_data[-1] | ||
|
||
module = importlib.import_module(module_path) | ||
return getattr(module, class_str) | ||
|
||
|
||
def before_send(event, hint): | ||
""" | ||
Workaround to prevent certain exceptions to be sent to sentry.io | ||
See: https://github.com/getsentry/sentry-python/issues/149#issuecomment-434448781 | ||
""" | ||
ignored_errors = () | ||
for error in settings.SENTRY_IGNORED_ERRORS: | ||
try: | ||
error_class = load_class(error) | ||
ignored_errors += (error_class,) | ||
except Exception: # pylint: disable=broad-except | ||
pass | ||
if 'exc_info' in hint and ignored_errors: | ||
_exc_type, exc_value, _tb = hint['exc_info'] | ||
if isinstance(exc_value, ignored_errors): | ||
return None | ||
|
||
return event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 2.8.1 | ||
current_version = 2.9.0 | ||
commit = True | ||
tag = True | ||
|
||
|