diff --git a/include/haproxy/counters-t.h b/include/haproxy/counters-t.h index 849f09683..933c228f0 100644 --- a/include/haproxy/counters-t.h +++ b/include/haproxy/counters-t.h @@ -36,9 +36,10 @@ struct fe_counters { long long bytes_in; /* number of bytes transferred from the client to the server */ long long bytes_out; /* number of bytes transferred from the server to the client */ - long long comp_in; /* input bytes fed to the compressor */ - long long comp_out; /* output bytes emitted by the compressor */ - long long comp_byp; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */ + /* compression counters, index 0 for requests, 1 for responses */ + long long comp_in[2]; /* input bytes fed to the compressor */ + long long comp_out[2]; /* output bytes emitted by the compressor */ + long long comp_byp[2]; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */ long long denied_req; /* blocked requests because of security concerns */ long long denied_resp; /* blocked responses because of security concerns */ @@ -80,9 +81,10 @@ struct be_counters { long long bytes_in; /* number of bytes transferred from the client to the server */ long long bytes_out; /* number of bytes transferred from the server to the client */ - long long comp_in; /* input bytes fed to the compressor */ - long long comp_out; /* output bytes emitted by the compressor */ - long long comp_byp; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */ + /* compression counters, index 0 for requests, 1 for responses */ + long long comp_in[2]; /* input bytes fed to the compressor */ + long long comp_out[2]; /* output bytes emitted by the compressor */ + long long comp_byp[2]; /* input bytes that bypassed the compressor (cpu/ram/bw limitation) */ long long denied_req; /* blocked requests because of security concerns */ long long denied_resp; /* blocked responses because of security concerns */ diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 8c56d0a46..31c8e2171 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -277,14 +277,14 @@ comp_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg, if (st->comp_ctx[dir] && st->comp_ctx[dir]->cur_lvl > 0) { update_freq_ctr(&global.comp_bps_in, consumed); - _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in, consumed); - _HA_ATOMIC_ADD(&s->be->be_counters.comp_in, consumed); + _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in[dir], consumed); + _HA_ATOMIC_ADD(&s->be->be_counters.comp_in[dir], consumed); update_freq_ctr(&global.comp_bps_out, to_forward); - _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out, to_forward); - _HA_ATOMIC_ADD(&s->be->be_counters.comp_out, to_forward); + _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out[dir], to_forward); + _HA_ATOMIC_ADD(&s->be->be_counters.comp_out[dir], to_forward); } else { - _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp, consumed); - _HA_ATOMIC_ADD(&s->be->be_counters.comp_byp, consumed); + _HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp[dir], consumed); + _HA_ATOMIC_ADD(&s->be->be_counters.comp_byp[dir], consumed); } return to_forward; diff --git a/src/stats.c b/src/stats.c index 0fe7e20fc..a90a39c43 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1847,13 +1847,13 @@ int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len, break; } case ST_F_COMP_IN: - metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_in); + metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_in[COMP_DIR_RES]); break; case ST_F_COMP_OUT: - metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_out); + metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_out[COMP_DIR_RES]); break; case ST_F_COMP_BYP: - metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_byp); + metric = mkf_u64(FN_COUNTER, px->fe_counters.comp_byp[COMP_DIR_RES]); break; case ST_F_COMP_RSP: metric = mkf_u64(FN_COUNTER, px->fe_counters.p.http.comp_rsp); @@ -2878,13 +2878,13 @@ int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int le metric = mkf_u64(FN_COUNTER, px->be_counters.srv_aborts); break; case ST_F_COMP_IN: - metric = mkf_u64(FN_COUNTER, px->be_counters.comp_in); + metric = mkf_u64(FN_COUNTER, px->be_counters.comp_in[COMP_DIR_RES]); break; case ST_F_COMP_OUT: - metric = mkf_u64(FN_COUNTER, px->be_counters.comp_out); + metric = mkf_u64(FN_COUNTER, px->be_counters.comp_out[COMP_DIR_RES]); break; case ST_F_COMP_BYP: - metric = mkf_u64(FN_COUNTER, px->be_counters.comp_byp); + metric = mkf_u64(FN_COUNTER, px->be_counters.comp_byp[COMP_DIR_RES]); break; case ST_F_COMP_RSP: metric = mkf_u64(FN_COUNTER, px->be_counters.p.http.comp_rsp);