]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: compression: Count separately request and response compression
authorOlivier Houchard <ohouchard@backtrace.io>
Wed, 5 Apr 2023 22:33:01 +0000 (00:33 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 6 Apr 2023 22:47:04 +0000 (00:47 +0200)
Duplicate the compression counters, so that we have separate counters
for request and response compression.

include/haproxy/counters-t.h
src/flt_http_comp.c
src/stats.c

index 849f0968389beda14a56e93e980b3e094ef81789..933c228f05b1619bd0d5353c63baf791eaf463dc 100644 (file)
@@ -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 */
index 8c56d0a46eb77a24602caa597c8f5aaa11f3bb86..31c8e2171c3fe2914bb40179d4dbfdcf15e32c01 100644 (file)
@@ -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;
 
index 0fe7e20fc40e2ee0e87d9b8eab258c314f44b5dd..a90a39c43748253af62846b8d508593fc7560655 100644 (file)
@@ -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);