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

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

commit 16a4755566a31004caf9a5feb7591f1d30def333
Author: Brian Neradt <[email protected]>
AuthorDate: Mon Apr 8 10:12:45 2024 -0500

    Fix parent proxy connection stat overcounting (#11220)
    
    The proxy.process.http.current_parent_proxy_connections and
    proxy.process.http.total_parent_proxy_connections stats are each
    incremented in create_server_txn, which is a fine place to increment
    them, but this assumes that each server transaction is associated with a
    single origin connection. This is not the case when sessions are reused.
    This fixes the counting by only incrementing these stats for the very
    first transaction in the session.
    
    (cherry picked from commit b674083c68be459f2bc60566418221253544909c)
---
 src/proxy/http/HttpSM.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/proxy/http/HttpSM.cc b/src/proxy/http/HttpSM.cc
index 6d4618e326..9ef713dbdd 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -1711,8 +1711,12 @@ HttpSM::create_server_txn(PoolableSession *new_session)
     server_txn->attach_transaction(this);
     if (t_state.current.request_to == ResolveInfo::PARENT_PROXY) {
       new_session->to_parent_proxy = true;
-      Metrics::Gauge::increment(http_rsb.current_parent_proxy_connections);
-      Metrics::Counter::increment(http_rsb.total_parent_proxy_connections);
+      if (server_txn->get_proxy_ssn()->get_transact_count() == 1) {
+        // These are connection-level metrics, so only increment them for the
+        // first transaction lest they get overcounted.
+        Metrics::Gauge::increment(http_rsb.current_parent_proxy_connections);
+        Metrics::Counter::increment(http_rsb.total_parent_proxy_connections);
+      }
     } else {
       new_session->to_parent_proxy = false;
     }

Reply via email to