mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-17 04:43:49 +01:00
Raise an appropriate error message if sentry_sdk missing
This commit is contained in:
parent
ef2228c890
commit
6a8f902edb
1 changed files with 15 additions and 1 deletions
|
@ -13,7 +13,16 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from ._base import Config
|
from ._base import Config, ConfigError
|
||||||
|
|
||||||
|
MISSING_SENTRY = (
|
||||||
|
"""Missing sentry_sdk library. This is required for enable sentry.io
|
||||||
|
integration.
|
||||||
|
|
||||||
|
Install by running:
|
||||||
|
pip install sentry_sdk
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MetricsConfig(Config):
|
class MetricsConfig(Config):
|
||||||
|
@ -25,6 +34,11 @@ class MetricsConfig(Config):
|
||||||
|
|
||||||
self.sentry_enabled = "sentry" in config
|
self.sentry_enabled = "sentry" in config
|
||||||
if self.sentry_enabled:
|
if self.sentry_enabled:
|
||||||
|
try:
|
||||||
|
import sentry_sdk # noqa F401
|
||||||
|
except ImportError:
|
||||||
|
raise ConfigError(MISSING_SENTRY)
|
||||||
|
|
||||||
self.sentry_dsn = config["sentry"]["dsn"]
|
self.sentry_dsn = config["sentry"]["dsn"]
|
||||||
|
|
||||||
def default_config(self, report_stats=None, **kwargs):
|
def default_config(self, report_stats=None, **kwargs):
|
||||||
|
|
Loading…
Reference in a new issue