Skip to content

Commit dc995b9

Browse files
committed
raven is outdated for py3.13 replace it with sentry_sdk to make it possible to build MFR 3.13 image and create containers afterward
1 parent de59e1e commit dc995b9

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

mfr/server/app.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import tornado.web
88
import tornado.httpserver
99
import tornado.platform.asyncio
10-
from raven.contrib.tornado import AsyncSentryClient
10+
11+
import sentry_sdk
12+
from sentry_sdk.integrations.tornado import TornadoIntegration
13+
from sentry_sdk.integrations.logging import LoggingIntegration
1114

1215
from mfr import settings
1316
from mfr.server import settings as server_settings
@@ -46,6 +49,15 @@ def almost_apache_style_log(handler):
4649

4750

4851
def make_app(debug):
52+
sentry_logging = LoggingIntegration(
53+
level=logging.INFO, # Capture INFO level and above as breadcrumbs
54+
event_level=None, # Do not send logs of any level as events
55+
)
56+
sentry_sdk.init(
57+
dsn=settings.SENTRY_DSN,
58+
release=__version__,
59+
integrations=[TornadoIntegration(), sentry_logging, ],
60+
)
4961
app = tornado.web.Application(
5062
[
5163
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': server_settings.STATIC_PATH}),
@@ -59,7 +71,6 @@ def make_app(debug):
5971
debug=debug,
6072
log_function=almost_apache_style_log,
6173
)
62-
app.sentry_client = AsyncSentryClient(settings.SENTRY_DSN, release=__version__)
6374
return app
6475

6576

mfr/server/handlers/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import tornado.web
99
import tornado.iostream
10-
from raven.contrib.tornado import SentryMixin
10+
import sentry_sdk
1111

1212
import waterbutler.core.utils
1313
import waterbutler.server.utils
@@ -76,7 +76,7 @@ def options(self):
7676
self.set_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE'),
7777

7878

79-
class BaseHandler(CorsMixin, tornado.web.RequestHandler, SentryMixin):
79+
class BaseHandler(CorsMixin, tornado.web.RequestHandler):
8080
"""Base class for the Render and Export handlers. Fetches the file metadata for the file
8181
indicated by the ``url`` query parameter and builds the provider caches. Also handles
8282
writing output and errors.
@@ -159,8 +159,11 @@ async def write_stream(self, stream):
159159
return
160160

161161
def write_error(self, status_code, exc_info):
162-
self.captureException(exc_info) # Log all non 2XX codes to sentry
163162
etype, exc, _ = exc_info
163+
scope = sentry_sdk.get_current_scope()
164+
scope.set_tag('class', etype.__name_)
165+
scope.set_tag('status_code', status_code)
166+
sentry_sdk.capture_exception(exc) # Log all non 2XX codes to sentry
164167

165168
if issubclass(etype, exceptions.PluginError):
166169
try: # clever errors shouldn't break other things

0 commit comments

Comments
 (0)