mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
Merge pull request #45 from Numigi/12.0-monitoring_log_requests_dispatch_classmethod
12.0: monitorin_log_request: _dispatch is a classmethod
This commit is contained in:
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
|
|
||||||
{'name': 'Monitoring: Requests Logging',
|
{'name': 'Monitoring: Requests Logging',
|
||||||
'version': '12.0.1.0.0',
|
'version': '12.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'],
|
||||||
|
|||||||
@@ -16,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
|
||||||
@@ -74,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