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 6219de1dff Fixes the TSMgmt metrics APIs for new API metrics (#10379)
6219de1dff is described below

commit 6219de1dff28e68ba455f960930db4632da25f23
Author: Leif Hedstrom <[email protected]>
AuthorDate: Wed Sep 6 12:21:50 2023 -0600

    Fixes the TSMgmt metrics APIs for new API metrics (#10379)
---
 src/traffic_server/InkAPI.cc | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index 035aaa6482..5a57796710 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -4419,15 +4419,42 @@ tsapi::c::TSMgmtUpdateRegister(TSCont contp, const char 
*plugin_name)
 TSReturnCode
 tsapi::c::TSMgmtIntGet(const char *var_name, TSMgmtInt *result)
 {
-  return RecGetRecordInt((char *)var_name, (RecInt *)result) == REC_ERR_OKAY ? 
TS_SUCCESS : TS_ERROR;
+  auto res = RecGetRecordInt((char *)var_name, (RecInt *)result);
+
+  // Try the old librecords first
+  if (res == REC_ERR_FAIL) {
+    int id = global_api_metrics.lookup(var_name);
+
+    if (id == ts::Metrics::NOT_FOUND) {
+      return TS_ERROR;
+    } else {
+      *result = global_api_metrics[id].load();
+    }
+  }
+
+  return TS_SUCCESS;
 }
 
 TSReturnCode
 tsapi::c::TSMgmtCounterGet(const char *var_name, TSMgmtCounter *result)
 {
-  return RecGetRecordCounter((char *)var_name, (RecCounter *)result) == 
REC_ERR_OKAY ? TS_SUCCESS : TS_ERROR;
+  auto res = RecGetRecordCounter((char *)var_name, (RecCounter *)result);
+
+  // Try the old librecords first
+  if (res == REC_ERR_FAIL) {
+    int id = global_api_metrics.lookup(var_name);
+
+    if (id == ts::Metrics::NOT_FOUND) {
+      return TS_ERROR;
+    } else {
+      *result = global_api_metrics[id].load();
+    }
+  }
+
+  return TS_SUCCESS;
 }
 
+// ToDo: These don't have the new metrics, only librecords.
 TSReturnCode
 tsapi::c::TSMgmtFloatGet(const char *var_name, TSMgmtFloat *result)
 {

Reply via email to