]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: pass the appctx flags to stats_fill_info()
authorWilly Tarreau <w@1wt.eu>
Sat, 8 May 2021 05:43:53 +0000 (07:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 8 May 2021 08:52:12 +0000 (10:52 +0200)
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.

addons/promex/service-prometheus.c
include/haproxy/stats.h
src/hlua_fcn.c
src/stats.c

index e6023d353ef257632a553148d5e4cf511fedd4a6..ee7c38f76850d6194fc99902bb3178881e9ac806 100644 (file)
@@ -545,7 +545,7 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx)
        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++) {
index a97740d28b00cf4415927dbae61d4a3084fdda60..bdb9c076c2630e8050a88b2b1d0d8d5edacfd005 100644 (file)
@@ -45,7 +45,7 @@ int stats_putchk(struct channel *chn, struct htx *htx, struct buffer *chk);
 
 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,
index 46a807e58f4ef1da5a1c118285fde2deedc37be1..26aa509842cce9c818b1a8d6ecd015d2fdb8bee8 100644 (file)
@@ -356,7 +356,7 @@ static int hlua_get_info(lua_State *L)
 {
        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++) {
index b2bf8b2ab6ac88333d488836577648f90534aa10..b2bda29b4690b8564a76c4970e0f4f3767e11ebb 100644 (file)
@@ -4285,12 +4285,13 @@ static int stats_dump_typed_info_fields(struct buffer *out,
        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 @@ static int stats_dump_info_to_buffer(struct stream_interface *si)
 {
        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);