MINOR: stats: pass the appctx flags to stats_fill_info()
Currently the stats filling function knows nothing about the caller's
needs, so let's pass the STAT_* flags so that it can adapt to the
requester's constraints.
diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c
index e6023d3..ee7c38f 100644
--- a/addons/promex/service-prometheus.c
+++ b/addons/promex/service-prometheus.c
@@ -545,7 +545,7 @@
size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx));
int ret = 1;
- if (!stats_fill_info(info, INF_TOTAL_FIELDS))
+ if (!stats_fill_info(info, INF_TOTAL_FIELDS, 0))
return -1;
for (; appctx->st2 < INF_TOTAL_FIELDS; appctx->st2++) {
diff --git a/include/haproxy/stats.h b/include/haproxy/stats.h
index a97740d..bdb9c07 100644
--- a/include/haproxy/stats.h
+++ b/include/haproxy/stats.h
@@ -45,7 +45,7 @@
int stats_dump_one_line(const struct field *stats, size_t stats_count, struct appctx *appctx);
-int stats_fill_info(struct field *info, int len);
+int stats_fill_info(struct field *info, int len, uint flags);
int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len,
enum stat_field *selected_field);
int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags,
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index 46a807e..26aa509 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -356,7 +356,7 @@
{
int i;
- stats_fill_info(stats, STATS_LEN);
+ stats_fill_info(stats, STATS_LEN, 0);
lua_newtable(L);
for (i=0; i<INF_TOTAL_FIELDS; i++) {
diff --git a/src/stats.c b/src/stats.c
index b2bf8b2..b2bda29 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -4285,12 +4285,13 @@
return 1;
}
-/* Fill <info> with HAProxy global info. <info> is preallocated
- * array of length <len>. The length of the array must be
- * INF_TOTAL_FIELDS. If this length is less then this value, the
- * function returns 0, otherwise, it returns 1.
+/* Fill <info> with HAProxy global info. <info> is preallocated array of length
+ * <len>. The length of the array must be INF_TOTAL_FIELDS. If this length is
+ * less then this value, the function returns 0, otherwise, it returns 1. Some
+ * fields' presence or precision may depend on some of the STAT_* flags present
+ * in <flags>.
*/
-int stats_fill_info(struct field *info, int len)
+int stats_fill_info(struct field *info, int len, uint flags)
{
unsigned int up = (now.tv_sec - start_date.tv_sec);
struct buffer *out = get_trash_chunk();
@@ -4410,7 +4411,7 @@
{
struct appctx *appctx = __objt_appctx(si->end);
- if (!stats_fill_info(info, INF_TOTAL_FIELDS))
+ if (!stats_fill_info(info, INF_TOTAL_FIELDS, appctx->ctx.stats.flags))
return 0;
chunk_reset(&trash);