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

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new b674083c68 Fix parent proxy connection stat overcounting (#11220)
b674083c68 is described below

commit b674083c68be459f2bc60566418221253544909c
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.
---
 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 eee135e65d..7ca9febdbe 100644
--- a/src/proxy/http/HttpSM.cc
+++ b/src/proxy/http/HttpSM.cc
@@ -1717,8 +1717,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