[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
pull/2516/head
Florian Mounier 2022-01-04 12:13:46 +01:00 committed by prabakaran
parent e546324ee2
commit d438a30b7d
1 changed files with 6 additions and 0 deletions

View File

@ -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: