feat: add task statistics to pool info: runTime and waitTime
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 5 Jul 2023 07:13:26 +0000 (09:13 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 5 Jul 2023 07:13:26 +0000 (09:13 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
CHANGELOG.md
src/pools/abstract-pool.ts
src/pools/pool.ts

index 596b7f4d063d5ccb4aea6f63f8c9062719643051..df3eeb3046e72fb53ea62b528fe454ce1a3eb7a1 100644 (file)
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Added
 
 - Add minimum and maximum to internal measurement statistics.
+- Add `runTime` and `waitTime` to pool information.
 
 ## [2.6.8] - 2023-07-03
 
index 95df53b2861293c72e2ef6c1e00fa4a4fc5f2c21..fc703d144f2862690c078aef485a72ad74328c2e 100644 (file)
@@ -297,7 +297,37 @@ export abstract class AbstractPool<
         (accumulator, workerNode) =>
           accumulator + workerNode.usage.tasks.failed,
         0
-      )
+      ),
+      ...(this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
+        .runTime.aggregate && {
+        runTime: {
+          minimum: Math.min(
+            ...this.workerNodes.map(
+              workerNode => workerNode.usage.runTime.minimum
+            )
+          ),
+          maximum: Math.max(
+            ...this.workerNodes.map(
+              workerNode => workerNode.usage.runTime.maximum
+            )
+          )
+        }
+      }),
+      ...(this.workerChoiceStrategyContext.getTaskStatisticsRequirements()
+        .waitTime.aggregate && {
+        waitTime: {
+          minimum: Math.min(
+            ...this.workerNodes.map(
+              workerNode => workerNode.usage.waitTime.minimum
+            )
+          ),
+          maximum: Math.max(
+            ...this.workerNodes.map(
+              workerNode => workerNode.usage.waitTime.maximum
+            )
+          )
+        }
+      })
     }
   }
 
index bb28535b0e732c7eafee9fa353f38166999862e5..15654803d64f2a3e1d6924c5120d47c4f56a2283 100644 (file)
@@ -86,6 +86,14 @@ export interface PoolInfo {
   queuedTasks: number
   maxQueuedTasks: number
   failedTasks: number
+  runTime?: {
+    minimum: number
+    maximum: number
+  }
+  waitTime?: {
+    minimum: number
+    maximum: number
+  }
 }
 
 /**