mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-16 12:31:09 +01:00
MEDIUM: counters: change the fill_stats() API to pass the module and extra_counters
We'll soon need to iterate over thread groups in the fill_stats() functions, so let's first pass the extra_counters and stats_module pointers to the fill_stats functions. They now call EXTRA_COUNTERS_GET() themselves with these elements in order to retrieve the required pointer. Nothing else changed, and it's getting even a bit more transparent for callers. This doesn't change anything visible however.
This commit is contained in:
parent
56fc12d6fa
commit
95a9f472d2
@ -626,8 +626,6 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||
}
|
||||
|
||||
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_FE))
|
||||
continue;
|
||||
|
||||
@ -664,8 +662,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx)
|
||||
if ((px->flags & PR_FL_DISABLED) || px->uuid <= 0 || !(px->cap & PR_CAP_FE))
|
||||
goto next_px2;
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(px->extra_counters_fe, mod);
|
||||
if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
if (!mod->fill_stats(mod, px->extra_counters_fe, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
return -1;
|
||||
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
@ -817,8 +814,6 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||
}
|
||||
|
||||
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_LI))
|
||||
continue;
|
||||
|
||||
@ -864,8 +859,7 @@ static int promex_dump_listener_metrics(struct appctx *appctx, struct htx *htx)
|
||||
labels[lb_idx+1].name = ist("mod");
|
||||
labels[lb_idx+1].value = ist2(mod->name, strlen(mod->name));
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(li->extra_counters, mod);
|
||||
if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
if (!mod->fill_stats(mod, li->extra_counters, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
return -1;
|
||||
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
@ -1113,8 +1107,6 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
}
|
||||
|
||||
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_BE))
|
||||
continue;
|
||||
|
||||
@ -1151,8 +1143,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx)
|
||||
if ((px->flags & PR_FL_DISABLED) || px->uuid <= 0 || !(px->cap & PR_CAP_BE))
|
||||
goto next_px2;
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(px->extra_counters_be, mod);
|
||||
if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
if (!mod->fill_stats(mod, px->extra_counters_be, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
return -1;
|
||||
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
@ -1420,8 +1411,6 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||
}
|
||||
|
||||
list_for_each_entry_from(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (!(stats_px_get_cap(mod->domain_flags) & STATS_PX_CAP_SRV))
|
||||
continue;
|
||||
|
||||
@ -1471,8 +1460,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx)
|
||||
goto next_sv2;
|
||||
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(sv->extra_counters, mod);
|
||||
if (!mod->fill_stats(counters, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
if (!mod->fill_stats(mod, sv->extra_counters, stats + ctx->field_num, &ctx->mod_field_num))
|
||||
goto error;
|
||||
|
||||
val = stats[ctx->field_num + ctx->mod_field_num];
|
||||
|
||||
@ -521,8 +521,8 @@ struct stats_module {
|
||||
struct list list;
|
||||
const char *name;
|
||||
|
||||
/* functor used to generate the stats module using counters provided through data parameter */
|
||||
int (*fill_stats)(void *data, struct field *, unsigned int *);
|
||||
/* function used to generate the stats module using counters provided through data parameter */
|
||||
int (*fill_stats)(struct stats_module *, struct extra_counters *, struct field *, unsigned int *);
|
||||
|
||||
struct stat_col *stats; /* statistics provided by the module */
|
||||
void *counters; /* initial values of allocated counters */
|
||||
|
||||
@ -129,9 +129,10 @@ static struct h3_counters {
|
||||
long long qpack_decoder_stream_error; /* total number of QPACK_DECODER_STREAM_ERROR errors received */
|
||||
} h3_counters;
|
||||
|
||||
static int h3_fill_stats(void *data, struct field *stats, unsigned int *selected_field)
|
||||
static int h3_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
|
||||
struct field *stats, unsigned int *selected_field)
|
||||
{
|
||||
struct h3_counters *counters = data;
|
||||
struct h3_counters *counters = EXTRA_COUNTERS_GET(ctr, mod);
|
||||
unsigned int current_field = (selected_field != NULL ? *selected_field : 0);
|
||||
|
||||
for (; current_field < H3_STATS_COUNT; current_field++) {
|
||||
|
||||
@ -272,9 +272,10 @@ static struct h1_counters {
|
||||
#endif
|
||||
} h1_counters;
|
||||
|
||||
static int h1_fill_stats(void *data, struct field *stats, unsigned int *selected_field)
|
||||
static int h1_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
|
||||
struct field *stats, unsigned int *selected_field)
|
||||
{
|
||||
struct h1_counters *counters = data;
|
||||
struct h1_counters *counters = EXTRA_COUNTERS_GET(ctr, mod);
|
||||
unsigned int current_field = (selected_field != NULL ? *selected_field : 0);
|
||||
|
||||
for (; current_field < H1_STATS_COUNT; current_field++) {
|
||||
|
||||
@ -371,9 +371,10 @@ static struct h2_counters {
|
||||
long long total_streams; /* total number of streams */
|
||||
} h2_counters;
|
||||
|
||||
static int h2_fill_stats(void *data, struct field *stats, unsigned int *selected_field)
|
||||
static int h2_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
|
||||
struct field *stats, unsigned int *selected_field)
|
||||
{
|
||||
struct h2_counters *counters = data;
|
||||
struct h2_counters *counters = EXTRA_COUNTERS_GET(ctr, mod);
|
||||
unsigned int current_field = (selected_field != NULL ? *selected_field : 0);
|
||||
|
||||
for (; current_field < H2_STATS_COUNT; current_field++) {
|
||||
|
||||
@ -92,9 +92,10 @@ static struct stat_col quic_stats[] = {
|
||||
|
||||
struct quic_counters quic_counters;
|
||||
|
||||
static int quic_fill_stats(void *data, struct field *stats, unsigned int *selected_field)
|
||||
static int quic_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
|
||||
struct field *stats, unsigned int *selected_field)
|
||||
{
|
||||
struct quic_counters *counters = data;
|
||||
struct quic_counters *counters = EXTRA_COUNTERS_GET(ctr, mod);
|
||||
unsigned int current_field = (selected_field != NULL ? *selected_field : 0);
|
||||
|
||||
for (; current_field < QUIC_STATS_COUNT; current_field++) {
|
||||
|
||||
@ -122,9 +122,10 @@ static struct stat_col resolv_stats[] = {
|
||||
|
||||
static struct dns_counters dns_counters;
|
||||
|
||||
static int resolv_fill_stats(void *d, struct field *stats, unsigned int *selected_field)
|
||||
static int resolv_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
|
||||
struct field *stats, unsigned int *selected_field)
|
||||
{
|
||||
struct dns_counters *counters = d;
|
||||
struct dns_counters *counters = EXTRA_COUNTERS_GET(ctr, mod);
|
||||
unsigned int current_field = (selected_field != NULL ? *selected_field : 0);
|
||||
|
||||
for (; current_field < RSLV_STAT_END; current_field++) {
|
||||
@ -2804,9 +2805,7 @@ static int stats_dump_resolv_to_buffer(struct stconn *sc,
|
||||
memset(stats, 0, sizeof(struct field) * stats_count);
|
||||
|
||||
list_for_each_entry(mod, stat_modules, list) {
|
||||
struct counters_node *counters = EXTRA_COUNTERS_GET(ns->extra_counters, mod);
|
||||
|
||||
if (!mod->fill_stats(counters, stats + idx, NULL))
|
||||
if (!mod->fill_stats(mod, ns->extra_counters, stats + idx, NULL))
|
||||
continue;
|
||||
idx += mod->stats_count;
|
||||
}
|
||||
@ -4080,7 +4079,7 @@ static int rslv_promex_fill_ts(void *unused, void *metric_ctx, unsigned int id,
|
||||
labels[1].name = ist("nameserver");
|
||||
labels[1].value = ist(ns->id);
|
||||
|
||||
ret = resolv_fill_stats(ns->counters, stats, &id);
|
||||
ret = resolv_fill_stats(&rslv_stats_module, ns->extra_counters, stats, &id);
|
||||
if (ret == 1)
|
||||
*field = stats[id];
|
||||
return ret;
|
||||
|
||||
@ -194,9 +194,10 @@ static struct stat_col ssl_stats[] = {
|
||||
|
||||
static struct ssl_counters ssl_counters;
|
||||
|
||||
static int ssl_fill_stats(void *data, struct field *stats, unsigned int *selected_field)
|
||||
static int ssl_fill_stats(struct stats_module *mod, struct extra_counters *ctr,
|
||||
struct field *stats, unsigned int *selected_field)
|
||||
{
|
||||
struct ssl_counters *counters = data;
|
||||
struct ssl_counters *counters = EXTRA_COUNTERS_GET(ctr, mod);
|
||||
unsigned int current_field = (selected_field != NULL ? *selected_field : 0);
|
||||
|
||||
for (; current_field < SSL_ST_STATS_COUNT; current_field++) {
|
||||
|
||||
@ -548,8 +548,6 @@ static int stats_dump_fe_line(struct stconn *sc, struct proxy *px)
|
||||
return 0;
|
||||
|
||||
list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (ctx->flags & STAT_F_FMT_FILE)
|
||||
continue;
|
||||
|
||||
@ -558,8 +556,7 @@ static int stats_dump_fe_line(struct stconn *sc, struct proxy *px)
|
||||
continue;
|
||||
}
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(px->extra_counters_fe, mod);
|
||||
if (!mod->fill_stats(counters, line + stats_count, NULL))
|
||||
if (!mod->fill_stats(mod, px->extra_counters_fe, line + stats_count, NULL))
|
||||
continue;
|
||||
stats_count += mod->stats_count;
|
||||
}
|
||||
@ -699,8 +696,6 @@ static int stats_dump_li_line(struct stconn *sc, struct proxy *px, struct listen
|
||||
return 0;
|
||||
|
||||
list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (ctx->flags & STAT_F_FMT_FILE)
|
||||
continue;
|
||||
|
||||
@ -709,8 +704,7 @@ static int stats_dump_li_line(struct stconn *sc, struct proxy *px, struct listen
|
||||
continue;
|
||||
}
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(l->extra_counters, mod);
|
||||
if (!mod->fill_stats(counters, line + stats_count, NULL))
|
||||
if (!mod->fill_stats(mod, l->extra_counters, line + stats_count, NULL))
|
||||
continue;
|
||||
stats_count += mod->stats_count;
|
||||
}
|
||||
@ -1137,8 +1131,6 @@ static int stats_dump_sv_line(struct stconn *sc, struct proxy *px, struct server
|
||||
return 0;
|
||||
|
||||
list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
void *counters;
|
||||
|
||||
if (ctx->flags & STAT_F_FMT_FILE)
|
||||
continue;
|
||||
|
||||
@ -1150,8 +1142,7 @@ static int stats_dump_sv_line(struct stconn *sc, struct proxy *px, struct server
|
||||
continue;
|
||||
}
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(sv->extra_counters, mod);
|
||||
if (!mod->fill_stats(counters, line + stats_count, NULL))
|
||||
if (!mod->fill_stats(mod, sv->extra_counters, line + stats_count, NULL))
|
||||
continue;
|
||||
stats_count += mod->stats_count;
|
||||
}
|
||||
@ -1378,8 +1369,6 @@ static int stats_dump_be_line(struct stconn *sc, struct proxy *px)
|
||||
return 0;
|
||||
|
||||
list_for_each_entry(mod, &stats_module_list[STATS_DOMAIN_PROXY], list) {
|
||||
struct extra_counters *counters;
|
||||
|
||||
if (ctx->flags & STAT_F_FMT_FILE)
|
||||
continue;
|
||||
|
||||
@ -1391,8 +1380,7 @@ static int stats_dump_be_line(struct stconn *sc, struct proxy *px)
|
||||
continue;
|
||||
}
|
||||
|
||||
counters = EXTRA_COUNTERS_GET(px->extra_counters_be, mod);
|
||||
if (!mod->fill_stats(counters, line + stats_count, NULL))
|
||||
if (!mod->fill_stats(mod, px->extra_counters_be, line + stats_count, NULL))
|
||||
continue;
|
||||
stats_count += mod->stats_count;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user