summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Dauchy <wdauchy@gmail.com>2021-01-22 21:09:48 +0100
committerChristopher Faulet <cfaulet@haproxy.com>2021-01-25 15:53:28 +0100
commit2107a0faf5e0ca6b86f51366d4550fb8a48f9654 (patch)
tree19f75ac4c3efdf8a18a8f8a9f1f05f4ad5b96abb
parent18a2c6ed4980c8f0b28c9b32170b2d4fe4948d88 (diff)
downloadhaproxy-2107a0faf5e0ca6b86f51366d4550fb8a48f9654.tar.gz
CLEANUP: stats: improve field selection for frontend http fields
while working on backend/servers I realised I could have written that in a better way and avoid one extra break. This is slightly improving readiness. also while being here, fix function declaration which was not 100% accurate. this patch does not change the behaviour of the code. Signed-off-by: William Dauchy <wdauchy@gmail.com>
-rw-r--r--include/haproxy/stats.h2
-rw-r--r--src/stats.c45
2 files changed, 19 insertions, 28 deletions
diff --git a/include/haproxy/stats.h b/include/haproxy/stats.h
index eb72446ae..8210367ac 100644
--- a/include/haproxy/stats.h
+++ b/include/haproxy/stats.h
@@ -47,7 +47,7 @@ int stats_dump_one_line(const struct field *stats, size_t stats_count, struct ap
int stats_fill_info(struct field *info, int len);
int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len,
- enum stat_field *field);
+ enum stat_field *selected_field);
int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags,
struct field *stats, int len);
int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
diff --git a/src/stats.c b/src/stats.c
index 1b8fad340..dcb99f674 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1713,49 +1713,40 @@ int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len,
metric = mkf_u64(FN_COUNTER, px->fe_counters.internal_errors);
break;
case ST_F_HRSP_1XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[1]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[1]);
break;
case ST_F_HRSP_2XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[2]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[2]);
break;
case ST_F_HRSP_3XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[3]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[3]);
break;
case ST_F_HRSP_4XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[4]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[4]);
break;
case ST_F_HRSP_5XX:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[5]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[5]);
break;
case ST_F_HRSP_OTHER:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[0]);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.rsp[0]);
break;
case ST_F_INTERCEPTED:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.intercepted_req);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.intercepted_req);
break;
case ST_F_CACHE_LOOKUPS:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cache_lookups);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cache_lookups);
break;
case ST_F_CACHE_HITS:
- if (px->mode != PR_MODE_HTTP)
- break;
- metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cache_hits);
+ if (px->mode == PR_MODE_HTTP)
+ metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.cache_hits);
break;
case ST_F_REQ_RATE:
metric = mkf_u32(FN_RATE, read_freq_ctr(&px->fe_req_per_sec));