From 8f35318c8723066c92d5862f4a7e482f49e99f57 Mon Sep 17 00:00:00 2001 From: Kind Jeff Date: Mon, 28 Sep 2020 13:38:51 +0800 Subject: [PATCH] update from raven to sentry-sdk (#174) --- sea/contrib/extensions/sentry.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/sea/contrib/extensions/sentry.py b/sea/contrib/extensions/sentry.py index b097795..f068d64 100644 --- a/sea/contrib/extensions/sentry.py +++ b/sea/contrib/extensions/sentry.py @@ -1,7 +1,6 @@ -import logging -import raven -from raven.conf import setup_logging -from raven.handlers.logging import SentryHandler +import sentry_sdk +from sentry_sdk.integrations.logging import LoggingIntegration +from sentry_sdk.integrations import DidNotEnable class Sentry: @@ -10,14 +9,14 @@ def init_app(self, app): dsn = app.config.get('SENTRY_DSN') if dsn: config = app.config.get_namespace('SENTRY_') - self.client = raven.Client(**config) - handler = SentryHandler(self.client) - handler.setLevel(logging.ERROR) - setup_logging(handler) + sentry_logging = LoggingIntegration() + integrations = [sentry_logging] + try: - from raven.contrib.celery import ( - register_signal, register_logger_signal) - register_logger_signal(self.client) - register_signal(self.client) - except ImportError: + from sentry_sdk.integrations.celery import CeleryIntegration + + integrations.append(CeleryIntegration()) + except DidNotEnable: pass + + sentry_sdk.init(**config, integrations=integrations)