Skip to content

Commit

Permalink
fix name_prefix usage (#266)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jsurloppe authored Feb 23, 2022
1 parent 96ce8f0 commit ea8be8c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions faust/sensors/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ea8be8c

Please sign in to comment.