]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: counters: Add fields to store the max observed for {q,c,d,t}_time
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 8 Nov 2019 13:53:15 +0000 (14:53 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 15 Nov 2019 13:23:21 +0000 (14:23 +0100)
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.

include/types/counters.h
src/stats.c
src/stream.c

index 1898548741382961b2b307a99da9cbea26197148..97df045e3a08922424089258e49c3abe51209ffa 100644 (file)
@@ -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 {
index cf692dafdabf63337ab893f4d33e6ef8fffdd6ce..c68ab63e7850929b999ad5ed9863f7de07e61f95 100644 (file)
@@ -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)
index 58ebab6ab5b9b942feffc5912c0e595a49efd93c..2c0d2c895069a439b861c6ed4324f3afe5d7fae5 100644 (file)
@@ -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);
 }
 
 /*