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

cmcfarlen 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 8c3aa40c4f Use ts::Metrics for socks metrics (#12568)
8c3aa40c4f is described below

commit 8c3aa40c4f4a662c7fd5ae1daf6ef277b861f90a
Author: Chris McFarlen <[email protected]>
AuthorDate: Sat Oct 18 16:58:47 2025 -0400

    Use ts::Metrics for socks metrics (#12568)
---
 src/traffic_server/SocksProxy.cc | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/src/traffic_server/SocksProxy.cc b/src/traffic_server/SocksProxy.cc
index 37c0858d94..97aa76ac90 100644
--- a/src/traffic_server/SocksProxy.cc
+++ b/src/traffic_server/SocksProxy.cc
@@ -31,18 +31,17 @@
 #include "../iocore/eventsystem/P_VConnection.h"
 #include "iocore/utils/OneWayTunnel.h"
 #include "proxy/http/HttpSessionAccept.h"
+#include "tsutil/Metrics.h"
 
 static DbgCtl dbg_ctl_SocksProxy("SocksProxy");
 
-enum {
-  socksproxy_http_connections_stat,
-  socksproxy_tunneled_connections_stat,
-
-  socksproxy_stat_count
-};
-static RecRawStatBlock *socksproxy_stat_block;
-
-#define SOCKSPROXY_INC_STAT(x) RecIncrRawStat(socksproxy_stat_block, 
mutex->thread_holding, x)
+namespace
+{
+struct {
+  ts::Metrics::Counter::AtomicType *http_connections;
+  ts::Metrics::Counter::AtomicType *tunneled_connections;
+} stats;
+} // namespace
 
 struct SocksProxy;
 using SocksProxyHandler = int (SocksProxy::*)(int, void *);
@@ -508,7 +507,7 @@ SocksProxy::parse_socks_client_request(unsigned char *p)
     sendResp(true);
     state = HTTP_REQ;
   } else {
-    SOCKSPROXY_INC_STAT(socksproxy_tunneled_connections_stat);
+    ts::Metrics::Counter::increment(stats.tunneled_connections);
     Dbg(dbg_ctl_SocksProxy, "Tunnelling the connection for port %d", port);
 
     if (clientVC->socks_addr.type != SOCKS_ATYPE_IPV4) {
@@ -555,7 +554,7 @@ SocksProxy::state_handing_over_http_request(int event, 
[[maybe_unused]] void *da
   case VC_EVENT_WRITE_COMPLETE: {
     HttpSessionAccept::Options ha_opt;
 
-    SOCKSPROXY_INC_STAT(socksproxy_http_connections_stat);
+    ts::Metrics::Counter::increment(stats.http_connections);
     Dbg(dbg_ctl_SocksProxy, "Handing over the HTTP request");
 
     ha_opt.transport_type = clientVC->attributes;
@@ -707,15 +706,8 @@ start_SocksProxy(int port)
   opt.local_port = port;
   netProcessor.main_accept(new SocksAccepter(), NO_FD, opt);
 
-  socksproxy_stat_block = RecAllocateRawStatBlock(socksproxy_stat_count);
-
-  if (socksproxy_stat_block) {
-    RecRegisterRawStat(socksproxy_stat_block, RECT_PROCESS, 
"proxy.process.socks.proxy.http_connections", RECD_INT, RECP_PERSISTENT,
-                       socksproxy_http_connections_stat, RecRawStatSyncCount);
-
-    RecRegisterRawStat(socksproxy_stat_block, RECT_PROCESS, 
"proxy.process.socks.proxy.tunneled_connections", RECD_INT,
-                       RECP_PERSISTENT, socksproxy_tunneled_connections_stat, 
RecRawStatSyncCount);
-  }
+  stats.http_connections     = 
ts::Metrics::Counter::createPtr("proxy.process.socks.proxy.http_connections");
+  stats.tunneled_connections = 
ts::Metrics::Counter::createPtr("proxy.process.socks.proxy.tunneled_connections");
 }
 
 int

Reply via email to