diff --git a/sentry/hooks.py b/sentry/hooks.py index ecea39479..8539d5a18 100644 --- a/sentry/hooks.py +++ b/sentry/hooks.py @@ -6,6 +6,7 @@ from collections import abc import odoo.http from odoo.service import wsgi_server +from odoo.service.server import server from odoo.tools import config as odoo_config from . import const @@ -110,6 +111,11 @@ def initialize_sentry(config): for item in exclude_loggers: ignore_logger(item) + # The server app is already registered so patch it here + if server: + server.app = SentryWsgiMiddleware(server.app) + + # Patch the wsgi server in case of further registration wsgi_server.application = SentryWsgiMiddleware(wsgi_server.application) with sentry_sdk.push_scope() as scope: