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

[FIX] monitoring_log_requests: response_status_code #468

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions monitoring_log_requests/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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:
Copy link

@Ricardoalso Ricardoalso Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this not be misleading ? Or are we always sure that an inexistent status_code represents a 200 status code meaning that the request was successful 🤔
It is basically like setting "response_status_code": 200 in line 63

info["response_status_code"] = 200
if hasattr(request, "session"):
info.update(
{
Expand Down
6 changes: 6 additions & 0 deletions setup/monitoring_log_requests/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading