BUG/MINOR: contrib/prometheus-exporter: Add missing label for ST_F_HRSP_1XX
Since the labels are dynamically created for each metric, the "code" label
of the ST_F_HRSP_1XX field is missing. To fix the bug, this metric is
handled in the same way the other ST_F_HRSP_* field are. We only take care
to dump the metric header only once.
This bug was introduced by the commit 5a2f93873 ("MEDIUM:
contrib/prometheus-exporter: Use dynamic labels instead of static ones"). No
backport needed.
diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c
index 8674cf3..4ee223a 100644
--- a/contrib/prometheus-exporter/service-prometheus.c
+++ b/contrib/prometheus-exporter/service-prometheus.c
@@ -639,7 +639,6 @@
goto next_px;
case ST_F_REQ_RATE_MAX:
case ST_F_REQ_TOT:
- case ST_F_HRSP_1XX:
case ST_F_INTERCEPTED:
case ST_F_CACHE_LOOKUPS:
case ST_F_CACHE_HITS:
@@ -651,6 +650,7 @@
goto next_px;
val = stats[appctx->st2];
break;
+ case ST_F_HRSP_1XX:
case ST_F_HRSP_2XX:
case ST_F_HRSP_3XX:
case ST_F_HRSP_4XX:
@@ -658,7 +658,8 @@
case ST_F_HRSP_OTHER:
if (px->mode != PR_MODE_HTTP)
goto next_px;
- appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
+ if (appctx->st2 != ST_F_HRSP_1XX)
+ appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
labels[1].name = ist("code");
labels[1].value = promex_hrsp_code[appctx->st2 - ST_F_HRSP_1XX];
val = stats[appctx->st2];
@@ -770,7 +771,6 @@
val = mkf_flt(FN_MAX, secs);
break;
case ST_F_REQ_TOT:
- case ST_F_HRSP_1XX:
case ST_F_CACHE_LOOKUPS:
case ST_F_CACHE_HITS:
case ST_F_COMP_IN:
@@ -781,6 +781,7 @@
goto next_px;
val = stats[appctx->st2];
break;
+ case ST_F_HRSP_1XX:
case ST_F_HRSP_2XX:
case ST_F_HRSP_3XX:
case ST_F_HRSP_4XX:
@@ -788,7 +789,8 @@
case ST_F_HRSP_OTHER:
if (px->mode != PR_MODE_HTTP)
goto next_px;
- appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
+ if (appctx->st2 != ST_F_HRSP_1XX)
+ appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
labels[1].name = ist("code");
labels[1].value = promex_hrsp_code[appctx->st2 - ST_F_HRSP_1XX];
val = stats[appctx->st2];
@@ -938,11 +940,11 @@
val = mkf_flt(FN_DURATION, secs);
break;
case ST_F_REQ_TOT:
- case ST_F_HRSP_1XX:
if (px->mode != PR_MODE_HTTP)
goto next_px;
val = stats[appctx->st2];
break;
+ case ST_F_HRSP_1XX:
case ST_F_HRSP_2XX:
case ST_F_HRSP_3XX:
case ST_F_HRSP_4XX:
@@ -950,7 +952,8 @@
case ST_F_HRSP_OTHER:
if (px->mode != PR_MODE_HTTP)
goto next_px;
- appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
+ if (appctx->st2 != ST_F_HRSP_1XX)
+ appctx->ctx.stats.flags &= ~PROMEX_FL_METRIC_HDR;
labels[2].name = ist("code");
labels[2].value = promex_hrsp_code[appctx->st2 - ST_F_HRSP_1XX];
val = stats[appctx->st2];