mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
Backport monitoring_prometheus from 13.0
This commit is contained in:
@@ -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)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Monitoring: Prometheus Metrics",
|
"name": "Monitoring: Prometheus Metrics",
|
||||||
"version": "13.0.1.0.0",
|
"version": "10.0.1.0.0",
|
||||||
"author": "Camptocamp,Odoo Community Association (OCA)",
|
"author": "Camptocamp,Odoo Community Association (OCA)",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"category": "category",
|
"category": "category",
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright 2016-2021 Camptocamp SA
|
# Copyright 2016-2021 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
import logging
|
||||||
|
|
||||||
from odoo.http import Controller, route
|
from odoo.http import Controller, route
|
||||||
from prometheus_client import generate_latest
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from prometheus_client import generate_latest
|
||||||
|
except (ImportError, IOError) as err:
|
||||||
|
_logger.warning(err)
|
||||||
|
|
||||||
|
|
||||||
class PrometheusController(Controller):
|
class PrometheusController(Controller):
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright 2016-2021 Camptocamp SA
|
# Copyright 2016-2021 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
import logging
|
||||||
|
|
||||||
from odoo import models
|
from odoo import models
|
||||||
from odoo.http import request
|
from odoo.http import request
|
||||||
from prometheus_client import Summary, Counter
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from prometheus_client import Summary, Counter
|
||||||
|
except (ImportError, IOError) as err:
|
||||||
|
_logger.warning(err)
|
||||||
|
|
||||||
|
|
||||||
REQUEST_TIME = Summary(
|
REQUEST_TIME = Summary(
|
||||||
@@ -21,10 +29,10 @@ class IrHttp(models.AbstractModel):
|
|||||||
|
|
||||||
if path_info.startswith("/longpolling/"):
|
if path_info.startswith("/longpolling/"):
|
||||||
LONGPOLLING_COUNT.inc()
|
LONGPOLLING_COUNT.inc()
|
||||||
return super()._dispatch()
|
return super(IrHttp, cls)._dispatch()
|
||||||
|
|
||||||
if path_info.startswith("/metrics"):
|
if path_info.startswith("/metrics"):
|
||||||
return super()._dispatch()
|
return super(IrHttp, cls)._dispatch()
|
||||||
|
|
||||||
if path_info.startswith("/web/static"):
|
if path_info.startswith("/web/static"):
|
||||||
label = "assets"
|
label = "assets"
|
||||||
@@ -35,6 +43,6 @@ class IrHttp(models.AbstractModel):
|
|||||||
|
|
||||||
res = None
|
res = None
|
||||||
with REQUEST_TIME.labels(label).time():
|
with REQUEST_TIME.labels(label).time():
|
||||||
res = super()._dispatch()
|
res = super(IrHttp, cls)._dispatch()
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|||||||
Reference in New Issue
Block a user