diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dbf92ff1..b518033e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,6 @@ exclude: | ^base_fileurl_field/| ^cloud_platform_exoscale/| ^cloud_platform_ovh/| - ^monitoring_log_requests/| ^monitoring_statsd/| ^test_base_fileurl_field/| # END NOT INSTALLABLE ADDONS diff --git a/monitoring_log_requests/models/ir_http.py b/monitoring_log_requests/models/ir_http.py index 3df49231..f0341f6e 100644 --- a/monitoring_log_requests/models/ir_http.py +++ b/monitoring_log_requests/models/ir_http.py @@ -6,7 +6,7 @@ import time from odoo import models -from odoo.http import request as http_request +from odoo.http import Response, request as http_request from odoo.tools.config import config _logger = logging.getLogger("monitoring.http.requests") @@ -30,7 +30,7 @@ def _dispatch(cls, endpoint): @classmethod def _monitoring_blacklist(cls, request): path_info = request.httprequest.environ.get("PATH_INFO") - if path_info.startswith("/longpolling/"): + if path_info.startswith(("/longpolling/", "/websocket")): return True return False @@ -62,8 +62,10 @@ def _monitoring_info(cls, request, response, begin, end): # response things "response_status_code": None, } - if hasattr(request, "status_code"): - info["status_code"] = response.status_code + if isinstance(response, Response) and hasattr(response, "status_code"): + info["response_status_code"] = response.status_code + else: + info["response_status_code"] = 200 if hasattr(request, "session"): info.update( { diff --git a/setup/monitoring_log_requests/odoo/addons/monitoring_log_requests b/setup/monitoring_log_requests/odoo/addons/monitoring_log_requests new file mode 120000 index 00000000..8bcfc7a7 --- /dev/null +++ b/setup/monitoring_log_requests/odoo/addons/monitoring_log_requests @@ -0,0 +1 @@ +../../../../monitoring_log_requests \ No newline at end of file diff --git a/setup/monitoring_log_requests/setup.py b/setup/monitoring_log_requests/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/monitoring_log_requests/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)