File tree Expand file tree Collapse file tree 7 files changed +61
-2
lines changed
Expand file tree Collapse file tree 7 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,20 @@ The plugin offers some integrations listed below:
8080
8181 ```yaml
8282 EOX_CORE_SENTRY_INTEGRATION_DSN: <your DSN value>
83+ EOX_CORE_SENTRY_IGNORED_ERRORS: [] # optional
8384 ```
8485
8586 By default, **EOX_CORE_SENTRY_INTEGRATION_DSN** setting is None, which disables the sentry integration.
8687
88+ **EOX_CORE_SENTRY_IGNORED_ERRORS** is optional. It is a list of exceptions that wants to be ignored by sentry. For instance, it can be defined as:
89+
90+ ```yaml
91+ EOX_CORE_SENTRY_IGNORED_ERRORS: [
92+ 'xmodule.exceptions.NotFoundError',
93+ 'openedx.core.djangoapps.user_authn.exceptions.AuthFailedError',
94+ ]
95+ ```
96+
8797## Course Management automation compilation
8898
8999We use webpack to bundle the React js application and its dependencies,
Original file line number Diff line number Diff line change 11"""
22Init for main eox-core app
33"""
4- __version__ = '2.8.1 '
4+ __version__ = '2.9.0 '
Original file line number Diff line number Diff line change 1+ """
2+ This file implements utils used for sentry integration.
3+
4+ See: https://github.com/eduNEXT/eox-core#integrations-with-third-party-services
5+ """
6+ import importlib
7+
8+ from django .conf import settings
9+
10+
11+ def load_class (full_class_string ):
12+ """
13+ dynamically load a class from a string
14+ """
15+
16+ class_data = full_class_string .split ("." )
17+ module_path = "." .join (class_data [:- 1 ])
18+ class_str = class_data [- 1 ]
19+
20+ module = importlib .import_module (module_path )
21+ return getattr (module , class_str )
22+
23+
24+ def before_send (event , hint ):
25+ """
26+ Workaround to prevent certain exceptions to be sent to sentry.io
27+ See: https://github.com/getsentry/sentry-python/issues/149#issuecomment-434448781
28+ """
29+ ignored_errors = ()
30+ for error in settings .SENTRY_IGNORED_ERRORS :
31+ try :
32+ error_class = load_class (error )
33+ ignored_errors += (error_class ,)
34+ except Exception : # pylint: disable=broad-except
35+ pass
36+ if 'exc_info' in hint and ignored_errors :
37+ _exc_type , exc_value , _tb = hint ['exc_info' ]
38+ if isinstance (exc_value , ignored_errors ):
39+ return None
40+
41+ return event
Original file line number Diff line number Diff line change @@ -119,8 +119,15 @@ def plugin_settings(settings): # pylint: disable=function-redefined
119119 'EOX_CORE_SENTRY_INTEGRATION_DSN' ,
120120 settings .EOX_CORE_SENTRY_INTEGRATION_DSN
121121 )
122+ settings .EOX_CORE_SENTRY_IGNORED_ERRORS = getattr (settings , 'ENV_TOKENS' , {}).get (
123+ 'EOX_CORE_SENTRY_IGNORED_ERRORS' ,
124+ settings .EOX_CORE_SENTRY_IGNORED_ERRORS
125+ )
126+
122127 if sentry_sdk is not None and sentry_integration_dsn is not None :
128+ from eox_core .integrations .sentry import before_send
123129 sentry_sdk .init (
130+ before_send = before_send ,
124131 dsn = sentry_integration_dsn ,
125132 integrations = [DjangoIntegration ()],
126133
Original file line number Diff line number Diff line change @@ -49,3 +49,4 @@ def plugin_settings(settings):
4949
5050 # Sentry Integration
5151 settings .EOX_CORE_SENTRY_INTEGRATION_DSN = None
52+ settings .EOX_CORE_SENTRY_IGNORED_ERRORS = []
Original file line number Diff line number Diff line change 11[bumpversion]
2- current_version = 2.8.1
2+ current_version = 2.9.0
33commit = True
44tag = True
55
You can’t perform that action at this time.
0 commit comments