diff --git a/setup.cfg b/setup.cfg index 9fc9dc45f8..b666ed32e8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -58,6 +58,7 @@ install_requires = OpenTimelineIO==0.15.0 orjson==3.9.7 pillow==10.0.1 + prometheus-flask-exporter==0.22.4 psutil==5.9.5 psycopg[binary]==3.1.12 pygelf==0.4.2 diff --git a/zou/app/__init__.py b/zou/app/__init__.py index 2dd2852471..9597bcc5a1 100644 --- a/zou/app/__init__.py +++ b/zou/app/__init__.py @@ -162,8 +162,24 @@ def add_permissions(_, payload): def load_api(): from zou.app import api + from zou import __version__ as zou_version api.configure(app) + try: + from prometheus_flask_exporter.multiprocess import ( + GunicornPrometheusMetrics, + ) + + metrics = GunicornPrometheusMetrics( + app, defaults_prefix="zou", group_by="url_rule" + ) + except ValueError: + from prometheus_flask_exporter import RESTfulPrometheusMetrics + + metrics = RESTfulPrometheusMetrics( + app, api, defaults_prefix="zou", group_by="url_rule" + ) + metrics.info("zou_info", "Application info", version=zou_version) fs.mkdir_p(app.config["TMP_DIR"]) configure_auth()