You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2022/04/05 19:10:11 UTC

[trafficserver] branch 9.2.x updated: Add metrics for loop detection. (#8772)

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new fba682558 Add metrics for loop detection. (#8772)
fba682558 is described below

commit fba682558311f0ae2783f520ca36d9fb1d4d7abc
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Wed Mar 30 23:12:49 2022 -0500

    Add metrics for loop detection. (#8772)
    
    Co-authored-by: Chris McFarlen <cm...@apple.com>
    (cherry picked from commit 39c3de51a6514b6c092252cfb51f73c92af4ec7e)
---
 .../monitoring/statistics/core/http-connection.en.rst          | 10 ++++++++++
 proxy/http/HttpConfig.cc                                       |  6 ++++++
 proxy/http/HttpConfig.h                                        |  2 ++
 proxy/http/HttpTransact.cc                                     |  2 ++
 4 files changed, 20 insertions(+)

diff --git a/doc/admin-guide/monitoring/statistics/core/http-connection.en.rst b/doc/admin-guide/monitoring/statistics/core/http-connection.en.rst
index 0baa9dba8..e00885c29 100644
--- a/doc/admin-guide/monitoring/statistics/core/http-connection.en.rst
+++ b/doc/admin-guide/monitoring/statistics/core/http-connection.en.rst
@@ -149,6 +149,16 @@ HTTP Connection
 
    Tracks the number of client requests that did not have a request sent to the origin server because the origin server was marked dead.
 
+.. ts:stat:: global proxy.process.http.http_proxy_loop_detected integer
+   :type: counter
+
+   Counts the number of times a proxy loop was detected
+
+.. ts:stat:: global proxy.process.http.http_proxy_mh_loop_detected integer
+   :type: counter
+
+   Counts the number of times a multi-hop proxy loop was detected
+
 HTTP/2
 ------
 
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index c1d8c4618..8f64efbbd 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -495,6 +495,12 @@ register_stat_callbacks()
   RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.extension_method_requests", RECD_COUNTER, RECP_PERSISTENT,
                      (int)http_extension_method_requests_stat, RecRawStatSyncCount);
 
+  RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.http_proxy_loop_detected", RECD_COUNTER, RECP_PERSISTENT,
+                     (int)http_proxy_loop_detected_stat, RecRawStatSyncCount);
+
+  RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.http_proxy_mh_loop_detected", RECD_COUNTER, RECP_PERSISTENT,
+                     (int)http_proxy_mh_loop_detected_stat, RecRawStatSyncCount);
+
   RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.broken_server_connections", RECD_COUNTER, RECP_PERSISTENT,
                      (int)http_broken_server_connections_stat, RecRawStatSyncCount);
 
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 145fffe10..dad111156 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -112,6 +112,8 @@ enum {
   http_purge_requests_stat,
   http_connect_requests_stat,
   http_extension_method_requests_stat,
+  http_proxy_loop_detected_stat,
+  http_proxy_mh_loop_detected_stat,
 
   http_completed_requests_stat,
   http_broken_server_connections_stat,
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 19e1e6c0f..2c8d260f0 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -6723,6 +6723,7 @@ HttpTransact::will_this_request_self_loop(State *s)
           break;
         }
         SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED);
+        HTTP_INCREMENT_DYN_STAT(http_proxy_loop_detected_stat);
         build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Cycle Detected", "request#cycle_detected");
         return true;
       }
@@ -6756,6 +6757,7 @@ HttpTransact::will_this_request_self_loop(State *s)
     if (count > max_proxy_cycles) {
       TxnDebug("http_transact", "count = %d > max_proxy_cycles = %d : detected loop", count, max_proxy_cycles);
       SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED);
+      HTTP_INCREMENT_DYN_STAT(http_proxy_mh_loop_detected_stat);
       build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Multi-Hop Cycle Detected", "request#cycle_detected");
       return true;
     } else {