mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-24 15:21:29 +02:00
MINOR: stats: make stats_dump_fields_json() directly take flags
It used to take an inverted flag for STAT_STARTED, let's make it take the raw flags instead.
This commit is contained in:
parent
ab02b3f345
commit
b0ce3ad9ff
12
src/stats.c
12
src/stats.c
@ -603,12 +603,12 @@ err:
|
|||||||
/* Dump all fields from <stats> into <out> using a typed "field:desc:type:value" format */
|
/* Dump all fields from <stats> into <out> using a typed "field:desc:type:value" format */
|
||||||
static int stats_dump_fields_json(struct buffer *out,
|
static int stats_dump_fields_json(struct buffer *out,
|
||||||
const struct field *stats,
|
const struct field *stats,
|
||||||
int first_stat)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int field;
|
int field;
|
||||||
int started = 0;
|
int started = 0;
|
||||||
|
|
||||||
if (!first_stat && !chunk_strcat(out, ","))
|
if ((flags & STAT_STARTED) && !chunk_strcat(out, ","))
|
||||||
return 0;
|
return 0;
|
||||||
if (!chunk_strcat(out, "["))
|
if (!chunk_strcat(out, "["))
|
||||||
return 0;
|
return 0;
|
||||||
@ -663,8 +663,8 @@ static int stats_dump_fields_json(struct buffer *out,
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
chunk_reset(out);
|
chunk_reset(out);
|
||||||
if (!first_stat)
|
if (flags & STAT_STARTED)
|
||||||
chunk_strcat(out, ",");
|
chunk_strcat(out, ",");
|
||||||
chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}");
|
chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1362,9 +1362,7 @@ int stats_dump_one_line(const struct field *stats, unsigned int flags, struct pr
|
|||||||
else if (appctx->ctx.stats.flags & STAT_FMT_TYPED)
|
else if (appctx->ctx.stats.flags & STAT_FMT_TYPED)
|
||||||
ret = stats_dump_fields_typed(&trash, stats);
|
ret = stats_dump_fields_typed(&trash, stats);
|
||||||
else if (appctx->ctx.stats.flags & STAT_FMT_JSON)
|
else if (appctx->ctx.stats.flags & STAT_FMT_JSON)
|
||||||
ret = stats_dump_fields_json(&trash, stats,
|
ret = stats_dump_fields_json(&trash, stats, appctx->ctx.stats.flags);
|
||||||
!(appctx->ctx.stats.flags &
|
|
||||||
STAT_STARTED));
|
|
||||||
else
|
else
|
||||||
ret = stats_dump_fields_csv(&trash, stats);
|
ret = stats_dump_fields_csv(&trash, stats);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user