]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: Be able to access to registered stats modules from anywhere
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Jan 2024 15:34:23 +0000 (16:34 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 1 Feb 2024 11:00:53 +0000 (12:00 +0100)
The list of modules registered on the stats to expose extra counters is now
public. It is required to export these counters into the Prometheus
exporter.

include/haproxy/stats.h
src/stats.c

index f9e6d97e2b148825a3171fe1f382c3bad9e57a84..eef800452f609902b1ede4a2d7e2c803c33f88fb 100644 (file)
@@ -41,6 +41,7 @@ extern const struct name_desc stat_fields[];
 extern const struct name_desc info_fields[];
 extern const char *stat_status_codes[];
 extern struct applet http_stats_applet;
+extern struct list stats_module_list[];
 extern THREAD_LOCAL struct field info[];
 extern THREAD_LOCAL struct field *stat_l[];
 
@@ -129,6 +130,16 @@ static inline struct field mkf_flt(uint32_t type, double value)
 #define MK_STATS_PROXY_DOMAIN(px_cap) \
        ((px_cap) << STATS_PX_CAP | STATS_DOMAIN_PROXY)
 
+static inline uint8_t stats_get_domain(uint32_t domain)
+{
+       return domain >> STATS_DOMAIN & STATS_DOMAIN_MASK;
+}
+
+static inline enum stats_domain_px_cap stats_px_get_cap(uint32_t domain)
+{
+       return domain >> STATS_PX_CAP & STATS_PX_CAP_MASK;
+}
+
 int stats_allocate_proxy_counters_internal(struct extra_counters **counters,
                                            int type, int px_cap);
 int stats_allocate_proxy_counters(struct proxy *px);
index 95f40fef8c103c0b27098bd7e068f564d0e62c6a..5547999747be91be3964a8299c1a66bfaa22da6e 100644 (file)
@@ -289,7 +289,7 @@ static size_t stat_count[STATS_DOMAIN_COUNT];
 THREAD_LOCAL struct field *stat_l[STATS_DOMAIN_COUNT];
 
 /* list of all registered stats module */
-static struct list stats_module_list[STATS_DOMAIN_COUNT] = {
+struct list stats_module_list[STATS_DOMAIN_COUNT] = {
        LIST_HEAD_INIT(stats_module_list[STATS_DOMAIN_PROXY]),
        LIST_HEAD_INIT(stats_module_list[STATS_DOMAIN_RESOLVERS]),
 };
@@ -298,16 +298,6 @@ THREAD_LOCAL void *trash_counters;
 static THREAD_LOCAL struct buffer trash_chunk = BUF_NULL;
 
 
-static inline uint8_t stats_get_domain(uint32_t domain)
-{
-       return domain >> STATS_DOMAIN & STATS_DOMAIN_MASK;
-}
-
-static inline enum stats_domain_px_cap stats_px_get_cap(uint32_t domain)
-{
-       return domain >> STATS_PX_CAP & STATS_PX_CAP_MASK;
-}
-
 static void stats_dump_json_schema(struct buffer *out);
 
 int stats_putchk(struct appctx *appctx, struct htx *htx)