diff --git a/monitoring_prometheus/__manifest__.py b/monitoring_prometheus/__manifest__.py index 22594d4..3fa7ae6 100644 --- a/monitoring_prometheus/__manifest__.py +++ b/monitoring_prometheus/__manifest__.py @@ -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": "9.0.1.0.0", "author": "Camptocamp,Odoo Community Association (OCA)", "license": "AGPL-3", "category": "category", diff --git a/monitoring_prometheus/controllers/prometheus_metrics.py b/monitoring_prometheus/controllers/prometheus_metrics.py index 411a2ac..2aca0cc 100644 --- a/monitoring_prometheus/controllers/prometheus_metrics.py +++ b/monitoring_prometheus/controllers/prometheus_metrics.py @@ -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 -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): diff --git a/monitoring_prometheus/models/ir_http.py b/monitoring_prometheus/models/ir_http.py index 0c026d6..f610ef1 100644 --- a/monitoring_prometheus/models/ir_http.py +++ b/monitoring_prometheus/models/ir_http.py @@ -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 -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( @@ -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