Damans227 commented on code in PR #13650:
URL: https://github.com/apache/cloudstack/pull/13650#discussion_r4194880982


##########
plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterImpl.java:
##########
@@ -491,13 +490,20 @@ private void addVMsBySizeMetrics(final List<Item> 
metricsList, final long dcId,
     }
 
     @Override
-    public void updateMetrics() {
+    public synchronized void updateMetrics() {
+        final long minIntervalMs = 
TimeUnit.SECONDS.toMillis(PrometheusExporterServer.PrometheusExporterMinRefreshInterval.value());
+        final long now = System.currentTimeMillis();

Review Comment:
   that covers it, thanks. the clock going back cant skip scrapes now



##########
server/src/main/java/com/cloud/alert/AlertManagerImpl.java:
##########
@@ -281,6 +286,24 @@ public void sendAlert(AlertType alertType, long 
dataCenterId, Long podId, String
         }
     }
 
+    /**
+     * Shared, long-lived pool for capacity recalculation, reused across every
+     * recalculateHostCapacities()/recalculateStorageCapacities() call instead 
of creating and
+     * tearing down a new thread pool per invocation. Repeatedly 
creating/shutting down pools was
+     * unnecessary overhead under frequent callers (e.g. the Prometheus 
exporter used to trigger a
+     * full recalculation on every scrape, see 
https://github.com/apache/cloudstack/issues/13586).
+     * Lazily created so this remains safe for callers that invoke the 
recalculate methods directly
+     * without going through configure()/start() (e.g. unit tests).
+     */
+    private synchronized ExecutorService getCapacityExecutorService() {
+        if (capacityExecutorService == null || 
capacityExecutorService.isShutdown()) {
+            capacityExecutorService = Executors.newFixedThreadPool(
+                    Math.max(1, 
CapacityManager.CapacityCalculateWorkers.value()),

Review Comment:
   that covers it, thanks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to