From d438a30b7d47910fe6dcefcde5733781bca1a149 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Tue, 4 Jan 2022 12:13:46 +0100 Subject: [PATCH] [FIX] sentry: Patch odoo.service.server wsgi app Because post_load is called after odoo.service.server start It has already registered the unpatched odoo.service.wsgi_server.application So patch it here too. This enables wsgi performance reporting with sentry_traces_sample_rate --- sentry/hooks.py | 6 ++++++ 1 file changed, 6 insertions(+) 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: