MINOR: stats: Be able to access to registered stats modules from anywhere

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.
This commit is contained in:
Christopher Faulet 2024-01-29 16:34:23 +01:00
parent 42a97d9feb
commit fd366a106b
2 changed files with 12 additions and 11 deletions

View 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);

View 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)