From: Christopher Faulet Date: Fri, 8 Nov 2019 13:53:15 +0000 (+0100) Subject: MINOR: counters: Add fields to store the max observed for {q,c,d,t}_time X-Git-Tag: v2.1-dev5~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efb41f0d8d9c9faef604d6f09a595b09a441fae6;p=thirdparty%2Fhaproxy.git MINOR: counters: Add fields to store the max observed for {q,c,d,t}_time For backends and servers, some average times for last 1024 connections are already calculated. For the moment, the averages for the time passed in the queue, the connect time, the response time (for HTTP session only) and the total time are calculated. Now, in addition, the maximum time observed for these values are also stored. In addition, These new counters are cleared as all other max values with the CLI command "clear counters". This patch is related to #272. --- diff --git a/include/types/counters.h b/include/types/counters.h index 1898548741..97df045e3a 100644 --- a/include/types/counters.h +++ b/include/types/counters.h @@ -100,6 +100,7 @@ struct be_counters { long long down_trans; /* up->down transitions */ unsigned int q_time, c_time, d_time, t_time; /* sums of conn_time, queue_time, data_time, total_time */ + unsigned int qtime_max, ctime_max, dtime_max, ttime_max; /* maximum of conn_time, queue_time, data_time, total_time observed */ union { struct { diff --git a/src/stats.c b/src/stats.c index cf692dafda..c68ab63e78 100644 --- a/src/stats.c +++ b/src/stats.c @@ -3746,6 +3746,10 @@ static int cli_parse_clear_counters(char **args, char *payload, struct appctx *a px->be_counters.sps_max = 0; px->be_counters.cps_max = 0; px->be_counters.nbpend_max = 0; + px->be_counters.qtime_max = 0; + px->be_counters.ctime_max = 0; + px->be_counters.dtime_max = 0; + px->be_counters.ttime_max = 0; px->fe_counters.conn_max = 0; px->fe_counters.p.http.rps_max = 0; @@ -3760,6 +3764,10 @@ static int cli_parse_clear_counters(char **args, char *payload, struct appctx *a sv->counters.cur_sess_max = 0; sv->counters.nbpend_max = 0; sv->counters.sps_max = 0; + sv->counters.qtime_max = 0; + sv->counters.ctime_max = 0; + sv->counters.dtime_max = 0; + sv->counters.ttime_max = 0; } list_for_each_entry(li, &px->conf.listeners, by_fe) diff --git a/src/stream.c b/src/stream.c index 58ebab6ab5..2c0d2c8950 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2956,11 +2956,19 @@ void stream_update_time_stats(struct stream *s) swrate_add(&srv->counters.c_time, TIME_STATS_SAMPLES, t_connect); swrate_add(&srv->counters.d_time, TIME_STATS_SAMPLES, t_data); swrate_add(&srv->counters.t_time, TIME_STATS_SAMPLES, t_close); + HA_ATOMIC_UPDATE_MAX(&srv->counters.qtime_max, t_queue); + HA_ATOMIC_UPDATE_MAX(&srv->counters.ctime_max, t_connect); + HA_ATOMIC_UPDATE_MAX(&srv->counters.dtime_max, t_data); + HA_ATOMIC_UPDATE_MAX(&srv->counters.ttime_max, t_close); } swrate_add(&s->be->be_counters.q_time, TIME_STATS_SAMPLES, t_queue); swrate_add(&s->be->be_counters.c_time, TIME_STATS_SAMPLES, t_connect); swrate_add(&s->be->be_counters.d_time, TIME_STATS_SAMPLES, t_data); swrate_add(&s->be->be_counters.t_time, TIME_STATS_SAMPLES, t_close); + HA_ATOMIC_UPDATE_MAX(&s->be->be_counters.qtime_max, t_queue); + HA_ATOMIC_UPDATE_MAX(&s->be->be_counters.ctime_max, t_connect); + HA_ATOMIC_UPDATE_MAX(&s->be->be_counters.dtime_max, t_data); + HA_ATOMIC_UPDATE_MAX(&s->be->be_counters.ttime_max, t_close); } /*