Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0] [FIX] sentry: Fix wsgi integration following HTTPocalypse #3223

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions sentry/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from collections import abc

import odoo.http
from odoo.service.server import server
from odoo.tools import config as odoo_config

from . import const
Expand Down Expand Up @@ -77,6 +76,16 @@ def get_odoo_commit(odoo_dir):
_logger.debug("Odoo directory: '%s' not a valid git repository", odoo_dir)


class OdooSentryWsgiMiddleware(SentryWsgiMiddleware):
"""
Odoo specific middleware to forward custom application attributes to the
odoo application.
"""

def __getattr__(self, item):
return getattr(self.app, item)


def initialize_sentry(config):
"""Setup an instance of :class:`sentry_sdk.Client`.
:param config: Sentry configuration
Expand Down Expand Up @@ -135,12 +144,7 @@ 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
odoo.http.Application = SentryWsgiMiddleware(odoo.http.Application)
odoo.http.root = OdooSentryWsgiMiddleware(odoo.http.root)

with sentry_sdk.push_scope() as scope:
scope.set_extra("debug", False)
Expand Down
Loading