diff --git a/dmci/__init__.py b/dmci/__init__.py index e0468dc..986f5cc 100644 --- a/dmci/__init__.py +++ b/dmci/__init__.py @@ -25,6 +25,7 @@ import logging from dmci.config import Config +from prometheus_flask_exporter import PrometheusMetrics def _init_logging(log_obj): @@ -80,6 +81,7 @@ def api_main(): sys.exit(1) dmci_app = App() + PrometheusMetrics(dmci_app) sys.exit(dmci_app.run()) # END api_main entry point diff --git a/requirements.txt b/requirements.txt index d080586..5789663 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ solrindexer @ git+https://github.com/metno/solr-indexer@v2.1.0 requests>=2.22 pyyaml>=5.1 flask>=1.0 +prometheus_flask_exporter lxml>=4.2.0 diff --git a/tests/test_core/test_init.py b/tests/test_core/test_init.py index cf5be88..0727a8d 100644 --- a/tests/test_core/test_init.py +++ b/tests/test_core/test_init.py @@ -76,6 +76,8 @@ def __init__(self): def run(self): return + monkeypatch.setattr("dmci.PrometheusMetrics", lambda x: False) + exampleConf = os.path.join(rootDir, "example_config.yaml") monkeypatch.setenv("DMCI_CONFIG", exampleConf) monkeypatch.setattr("dmci.api.App", mockAPI)