From 2f7a8dd952b1f77e6d635c7fe56fd00f169f6307 Mon Sep 17 00:00:00 2001 From: Julien Surloppe Date: Wed, 9 Feb 2022 15:24:56 +0100 Subject: [PATCH] fix name_prefix usage app name is used as fallback only if it contains dash plus lot of cases lead to prometheus naming exception simplify it by enforcing correct prometheus naming --- faust/sensors/prometheus.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/faust/sensors/prometheus.py b/faust/sensors/prometheus.py index 66829fef7..dca750752 100644 --- a/faust/sensors/prometheus.py +++ b/faust/sensors/prometheus.py @@ -59,20 +59,9 @@ def setup_prometheus_sensors( "prometheus_client requires `pip install prometheus_client`." ) if name_prefix is None: - app_conf_name = app.conf.name - app.logger.info( - "Name prefix is not supplied. Using the name %s from App config.", - app_conf_name, - ) - if "-" in app_conf_name: - name_prefix = app_conf_name.replace("-", "_") - app.logger.warning( - "App config name %s does not conform to" - " Prometheus naming conventions." - " Using %s as a name_prefix.", - app_conf_name, - name_prefix, - ) + name_prefix = app.conf.name + + name_prefix = name_prefix.replace("-", "_").replace(".", "_") faust_metrics = FaustMetrics.create(registry, name_prefix) app.monitor = PrometheusMonitor(metrics=faust_metrics)