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

zwoop 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 225c3bc6bd Move the H3 metrics stubs to new Metrics (#10604)
225c3bc6bd is described below

commit 225c3bc6bd7f87542d5c8ed989b0c8483a328aea
Author: Leif Hedstrom <[email protected]>
AuthorDate: Fri Oct 13 16:29:02 2023 -0600

    Move the H3 metrics stubs to new Metrics (#10604)
    
    * Move the H3 metrics stubs to new Metrics
    
    * Also migrates the quic_rsb
---
 iocore/net/QUICNetVConnection.cc |  2 +-
 iocore/net/quic/QUICGlobals.cc   | 15 ++++++---------
 iocore/net/quic/QUICStats.h      | 20 +++++---------------
 proxy/http2/HTTP2.cc             |  6 ------
 proxy/http3/Http3.cc             |  9 +++++++--
 proxy/http3/Http3.h              | 13 +++++++------
 6 files changed, 26 insertions(+), 39 deletions(-)

diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index e909d7f002..8d75c31c0e 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -1570,7 +1570,7 @@ QUICNetVConnection::_state_common_send_packet()
     this->_context->trigger(QUICContext::CallbackEvent::METRICS_UPDATE, 
this->_congestion_controller->congestion_window(),
                             this->_congestion_controller->bytes_in_flight(), 
this->_congestion_controller->current_ssthresh());
 
-    QUIC_INCREMENT_DYN_STAT_EX(QUICStats::total_packets_sent_stat, 
packet_count);
+    Metrics::increment(quic_rsb.total_packets_sent_stat, packet_count);
     net_activity(this, this_ethread());
   }
 
diff --git a/iocore/net/quic/QUICGlobals.cc b/iocore/net/quic/QUICGlobals.cc
index ceb97cc740..baae4b232b 100644
--- a/iocore/net/quic/QUICGlobals.cc
+++ b/iocore/net/quic/QUICGlobals.cc
@@ -37,7 +37,7 @@
 
 #define QUICGlobalDebug(fmt, ...) Debug("quic_global", fmt, ##__VA_ARGS__)
 
-RecRawStatBlock *quic_rsb;
+QuicStatsBlock quic_rsb;
 
 int QUIC::ssl_quic_qc_index  = -1;
 int QUIC::ssl_quic_tls_index = -1;
@@ -73,13 +73,10 @@ QUIC::ssl_client_new_session(SSL *ssl, SSL_SESSION *session)
 void
 QUIC::_register_stats()
 {
-  quic_rsb = RecAllocateRawStatBlock(static_cast<int>(QUICStats::count));
-
+  ts::Metrics &intm = ts::Metrics::getInstance();
   // Transferred packet counts
-  RecRegisterRawStat(quic_rsb, RECT_PROCESS, 
"proxy.process.quic.total_packets_sent", RECD_INT, RECP_PERSISTENT,
-                     static_cast<int>(QUICStats::total_packets_sent_stat), 
RecRawStatSyncSum);
-  // RecRegisterRawStat(quic_rsb, RECT_PROCESS, 
"proxy.process.quic.total_packets_retransmitted", RECD_INT, RECP_PERSISTENT,
-  //                              
static_cast<int>(quic_total_packets_retransmitted_stat), RecRawStatSyncSum);
-  // RecRegisterRawStat(quic_rsb, RECT_PROCESS, 
"proxy.process.quic.total_packets_received", RECD_INT, RECP_PERSISTENT,
-  //                            
static_cast<int>(quic_total_packets_received_stat), RecRawStatSyncSum);
+  quic_rsb.total_packets_sent = 
intm.newMetricPtr("proxy.process.quic.total_packets_sent");
+
+  // quic_rsb.total_packets_retransmitted = 
intm.newMetricPtr("proxy.process.quic.total_packets_retransmitted");
+  // quic_rsb.total_packets_received      = 
intm.newMetricPtr("proxy.process.quic.total_packets_received");
 }
diff --git a/iocore/net/quic/QUICStats.h b/iocore/net/quic/QUICStats.h
index f96206dd24..c429f83661 100644
--- a/iocore/net/quic/QUICStats.h
+++ b/iocore/net/quic/QUICStats.h
@@ -23,21 +23,11 @@
 
 #pragma once
 
-#include "records/I_RecProcess.h"
+#include "api/Metrics.h"
+using ts::Metrics;
 
-extern RecRawStatBlock *quic_rsb;
-
-enum class QUICStats {
-  total_packets_sent_stat,
-  count,
+struct QuicStatsBlock {
+  Metrics::IntType *total_packets_sent;
 };
 
-#define QUIC_INCREMENT_DYN_STAT(x)        RecIncrRawStat(quic_rsb, nullptr, 
(int)x, 1)
-#define QUIC_DECREMENT_DYN_STAT(x)        RecIncrRawStat(quic_rsb, nullptr, 
(int)x, -1)
-#define QUIC_SET_COUNT_DYN_STAT(x, count) RecSetRawStatCount(quic_rsb, x, 
count)
-#define QUIC_INCREMENT_DYN_STAT_EX(x, y)  RecIncrRawStat(quic_rsb, nullptr, 
(int)x, y)
-#define QUIC_CLEAR_DYN_STAT(x)            \
-  do {                                    \
-    RecSetRawStatSum(quic_rsb, (x), 0);   \
-    RecSetRawStatCount(quic_rsb, (x), 0); \
-  } while (0)
+extern QuicStatsBlock quic_rsb;
diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc
index becd55b199..ca226fe6b2 100644
--- a/proxy/http2/HTTP2.cc
+++ b/proxy/http2/HTTP2.cc
@@ -562,12 +562,6 @@ Http2::init()
   
ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_HEADER_TABLE_SIZE,
 header_table_size}));
   
ink_release_assert(http2_settings_parameter_is_valid({HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE,
 max_header_list_size}));
 
-#define HTTP2_CLEAR_DYN_STAT(x)          \
-  do {                                   \
-    RecSetRawStatSum(http2_rsb, x, 0);   \
-    RecSetRawStatCount(http2_rsb, x, 0); \
-  } while (0);
-
   // Setup statistics
   ts::Metrics &intm = ts::Metrics::getInstance();
 
diff --git a/proxy/http3/Http3.cc b/proxy/http3/Http3.cc
index 6405d411ac..ae1a8ae1f6 100644
--- a/proxy/http3/Http3.cc
+++ b/proxy/http3/Http3.cc
@@ -29,10 +29,15 @@ const uint32_t HTTP3_DEFAULT_MAX_FIELD_SECTION_SIZE = 
UINT32_MAX;
 const uint32_t HTTP3_DEFAULT_QPACK_BLOCKED_STREAMS  = 0;
 const uint32_t HTTP3_DEFAULT_NUM_PLACEHOLDERS       = 0;
 
-RecRawStatBlock *http3_rsb;
+Http3StatsBlock http3_rsb;
 
 void
 Http3::init()
 {
-  http3_rsb = RecAllocateRawStatBlock(static_cast<int>(HTTP3_N_STATS));
+  // Example (remove comments here when addding)
+  //
+  // Setup statistics
+  // ts::Metrics &intm = ts::Metrics::getInstance();
+  //
+  // http3_rsb.current_client_session_count = 
intm.newMetricPtr("proxy.process.http3.current_client_connections");
 }
diff --git a/proxy/http3/Http3.h b/proxy/http3/Http3.h
index 97c160298b..74f4b7e810 100644
--- a/proxy/http3/Http3.h
+++ b/proxy/http3/Http3.h
@@ -24,16 +24,13 @@
 #pragma once
 
 #include "tscore/ink_defs.h"
-#include "records/I_RecDefs.h"
-#include "records/I_RecProcess.h"
+#include "api/Metrics.h"
 
 extern const uint32_t HTTP3_DEFAULT_HEADER_TABLE_SIZE;
 extern const uint32_t HTTP3_DEFAULT_MAX_FIELD_SECTION_SIZE;
 extern const uint32_t HTTP3_DEFAULT_QPACK_BLOCKED_STREAMS;
 extern const uint32_t HTTP3_DEFAULT_NUM_PLACEHOLDERS;
 
-extern RecRawStatBlock *http3_rsb; // Container for statistics.
-
 class Http3
 {
 public:
@@ -41,6 +38,10 @@ public:
 };
 
 // Statistics
-enum {
-  HTTP3_N_STATS // Terminal counter, NOT A STAT INDEX.
+struct Http3StatsBlock {
+  // Example: Metrics::IntType *current_client_session_count;
+  // Once created, e.g.
+  // Metrics::increment(http3_rsb.current_client_session_count);
 };
+
+extern Http3StatsBlock http3_rsb; // Container for statistics.

Reply via email to