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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 63c6a93ef6 Update cache metrics after initialized (#12430) (#12469)
63c6a93ef6 is described below

commit 63c6a93ef655769af5b5d528c4adb5348b6be09a
Author: Masaori Koshiba <[email protected]>
AuthorDate: Mon Aug 25 23:39:48 2025 +0900

    Update cache metrics after initialized (#12430) (#12469)
    
    (cherry picked from commit c6d0b6cfbe0fa2f1bfa343c546528f376d8bb261)
    
    Conflicts:
            src/iocore/cache/CacheProcessor.cc
---
 src/iocore/cache/CacheProcessor.cc | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/iocore/cache/CacheProcessor.cc 
b/src/iocore/cache/CacheProcessor.cc
index 7c941fcb09..a1f6c827a0 100644
--- a/src/iocore/cache/CacheProcessor.cc
+++ b/src/iocore/cache/CacheProcessor.cc
@@ -128,6 +128,10 @@ CacheProcessor::start(int, size_t)
 void
 CachePeriodicMetricsUpdate()
 {
+  if (cacheProcessor.initialized != CACHE_INITIALIZED) {
+    return;
+  }
+
   int64_t total_sum = 0;
 
   // Make sure the bytes_used per volume is always reset to zero, this can 
update the
@@ -137,21 +141,19 @@ CachePeriodicMetricsUpdate()
     ts::Metrics::Gauge::store(gstripes[i]->cache_vol->vol_rsb.bytes_used, 0);
   }
 
-  if (cacheProcessor.initialized == CACHE_INITIALIZED) {
-    for (int i = 0; i < gnstripes; ++i) {
-      StripeSM *v    = gstripes[i];
-      int64_t   used = cache_bytes_used(i);
+  for (int i = 0; i < gnstripes; ++i) {
+    StripeSM *v    = gstripes[i];
+    int64_t   used = cache_bytes_used(i);
 
-      ts::Metrics::Gauge::increment(v->cache_vol->vol_rsb.bytes_used, used); 
// This assumes they start at zero
-      total_sum += used;
-    }
+    ts::Metrics::Gauge::increment(v->cache_vol->vol_rsb.bytes_used, used); // 
This assumes they start at zero
+    total_sum += used;
+  }
 
-    // Also update the global (not per volume) metrics
-    int64_t total = ts::Metrics::Gauge::load(cache_rsb.bytes_total);
+  // Also update the global (not per volume) metrics
+  int64_t total = ts::Metrics::Gauge::load(cache_rsb.bytes_total);
 
-    ts::Metrics::Gauge::store(cache_rsb.bytes_used, total_sum);
-    ts::Metrics::Gauge::store(cache_rsb.percent_full, total ? (total_sum * 
100) / total : 0);
-  }
+  ts::Metrics::Gauge::store(cache_rsb.bytes_used, total_sum);
+  ts::Metrics::Gauge::store(cache_rsb.percent_full, total ? (total_sum * 100) 
/ total : 0);
 }
 
 // ToDo: This gets called as part of librecords collection continuation, 
probably change this later.

Reply via email to