mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Merge pull request #44 from Numigi/11.0-monitoring_log_requests_dispatch_classmethod
monitoring_log_request: _dispatch is a classmethod
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
|
||||||
|
|
||||||
{'name': 'Monitoring: Requests Logging',
|
{'name': 'Monitoring: Requests Logging',
|
||||||
'version': '11.0.1.0.0',
|
'version': '11.0.2.0.0',
|
||||||
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
'author': 'Camptocamp,Numigi,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'category',
|
'category': 'category',
|
||||||
'depends': ['base', 'web'],
|
'depends': ['base', 'web'],
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2016 Camptocamp SA
|
# Copyright 2016 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
|
||||||
@@ -17,26 +16,30 @@ _logger = logging.getLogger('monitoring.http.requests')
|
|||||||
class IrHttp(models.AbstractModel):
|
class IrHttp(models.AbstractModel):
|
||||||
_inherit = 'ir.http'
|
_inherit = 'ir.http'
|
||||||
|
|
||||||
def _dispatch(self):
|
@classmethod
|
||||||
|
def _dispatch(cls):
|
||||||
begin = time.time()
|
begin = time.time()
|
||||||
response = super(IrHttp, self)._dispatch()
|
response = super(IrHttp, cls)._dispatch()
|
||||||
end = time.time()
|
end = time.time()
|
||||||
if (not self._monitoring_blacklist(http_request) and
|
if (not cls._monitoring_blacklist(http_request) and
|
||||||
self._monitoring_filter(http_request)):
|
cls._monitoring_filter(http_request)):
|
||||||
info = self._monitoring_info(http_request, response, begin, end)
|
info = cls._monitoring_info(http_request, response, begin, end)
|
||||||
self._monitoring_log(info)
|
cls._monitoring_log(info)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def _monitoring_blacklist(self, request):
|
@classmethod
|
||||||
|
def _monitoring_blacklist(cls, request):
|
||||||
path_info = request.httprequest.environ.get('PATH_INFO')
|
path_info = request.httprequest.environ.get('PATH_INFO')
|
||||||
if path_info.startswith('/longpolling/'):
|
if path_info.startswith('/longpolling/'):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _monitoring_filter(self, request):
|
@classmethod
|
||||||
|
def _monitoring_filter(cls, _):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _monitoring_info(self, request, response, begin, end):
|
@classmethod
|
||||||
|
def _monitoring_info(cls, request, response, begin, end):
|
||||||
path = request.httprequest.environ.get('PATH_INFO')
|
path = request.httprequest.environ.get('PATH_INFO')
|
||||||
info = {
|
info = {
|
||||||
# timing
|
# timing
|
||||||
@@ -75,5 +78,6 @@ class IrHttp(models.AbstractModel):
|
|||||||
})
|
})
|
||||||
return info
|
return info
|
||||||
|
|
||||||
def _monitoring_log(self, info):
|
@classmethod
|
||||||
|
def _monitoring_log(cls, info):
|
||||||
_logger.info(json.dumps(info))
|
_logger.info(json.dumps(info))
|
||||||
|
|||||||
Reference in New Issue
Block a user