9 azure backport (#353)

* fix: backport fix + backport modules to azure
This commit is contained in:
Vincent Renaville
2022-03-15 10:27:02 +01:00
committed by GitHub
co-authored by GitHub
parent 92bf8210ef
commit 61a7d392ff
19 changed files with 332 additions and 26 deletions
+2
View File
@@ -0,0 +1,2 @@
from __future__ import absolute_import
from . import ir_http
+50
View File
@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from __future__ import with_statement
from __future__ import absolute_import
import logging
from openerp import models
from openerp.http import request
_logger = logging.getLogger(__name__)
try:
from prometheus_client import Summary, Counter
except (ImportError, IOError), err:
_logger.warning(err)
REQUEST_TIME = Summary(
"request_latency_sec", "Request response time in sec", ["query_type"]
)
LONGPOLLING_COUNT = Counter("longpolling", "Longpolling request count")
class IrHttp(models.AbstractModel):
_inherit = "ir.http"
@classmethod
def _dispatch(cls):
path_info = request.httprequest.environ.get("PATH_INFO")
if path_info.startswith("/longpolling/"):
LONGPOLLING_COUNT.inc()
return super(IrHttp, cls)._dispatch()
if path_info.startswith("/metrics"):
return super(IrHttp, cls)._dispatch()
if path_info.startswith("/web/static"):
label = "assets"
elif path_info.startswith("/web/content"):
label = "filestore"
else:
label = "client"
res = None
with REQUEST_TIME.labels(label).time():
res = super(IrHttp, cls)._dispatch()
return res