[13.0][ADD] monitoring_prometheus (#239)

[13.0][ADD] monitoring_prometheus
This commit is contained in:
Patrick Tombez authored and Yannick Vaucher committed 2021-11-03 10:15:22 +01:00
1 parent 4b61f43f85
commit 5ff0df3f75
8 files changed
+95

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
# Copyright 2016-2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import models
from odoo.http import request
from prometheus_client import Summary, Counter
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()._dispatch()
if path_info.startswith("/metrics"):
return super()._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()._dispatch()
return res
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.