Files
session_redis_public/monitoring_prometheus/models/ir_http.py
T
Alexandre Fayolle 8a660b6081 [ADD] monitoring_prometheus_queue_job
This commit features a refactoring of monitoring_prometheus to get a
cron gathering some metrics from the database, and then publishing the
result on the /metrics endpoint

The new module monitoring_prometheus_queue_job extends the cron to get
information about the queue job states.
2026-09-30 19:33:16 +03:00

41 lines
1.1 KiB
Python

# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from prometheus_client import Counter, Summary
from odoo import models
from odoo.http import request
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