Backport monitoring_prometheus from 13.0

This commit is contained in:
Yannick Vaucher
2021-11-15 12:47:20 +01:00
parent 7401d6f204
commit 4223e926f8
3 changed files with 24 additions and 7 deletions
+3 -2
View File
@@ -1,10 +1,11 @@
# Copyright 2016-2019 Camptocamp SA
# -*- coding: utf-8 -*-
# Copyright 2016-2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
"name": "Monitoring: Prometheus Metrics",
"version": "13.0.1.0.0",
"version": "10.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "category",
@@ -1,8 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import logging
from odoo.http import Controller, route
_logger = logging.getLogger(__name__)
try:
from prometheus_client import generate_latest
except (ImportError, IOError) as err:
_logger.warning(err)
class PrometheusController(Controller):
+11 -3
View File
@@ -1,9 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import logging
from odoo import models
from odoo.http import request
_logger = logging.getLogger(__name__)
try:
from prometheus_client import Summary, Counter
except (ImportError, IOError) as err:
_logger.warning(err)
REQUEST_TIME = Summary(
@@ -21,10 +29,10 @@ class IrHttp(models.AbstractModel):
if path_info.startswith("/longpolling/"):
LONGPOLLING_COUNT.inc()
return super()._dispatch()
return super(IrHttp, cls)._dispatch()
if path_info.startswith("/metrics"):
return super()._dispatch()
return super(IrHttp, cls)._dispatch()
if path_info.startswith("/web/static"):
label = "assets"
@@ -35,6 +43,6 @@ class IrHttp(models.AbstractModel):
res = None
with REQUEST_TIME.labels(label).time():
res = super()._dispatch()
res = super(IrHttp, cls)._dispatch()
return res