iemre commented on code in PR #24598:
URL: https://github.com/apache/flink/pull/24598#discussion_r1551256100


##########
flink-runtime-web/web-dashboard/src/app/services/metrics.service.ts:
##########
@@ -71,45 +77,73 @@ export class MetricsService {
       );
   }
 
-  /** Get aggregated metric data from all subtasks of the given vertexId. */
-  public loadAggregatedMetrics(
+  /** Get aggregated metric data from all subtasks of the given vertexId. 
Example output:
+  { "numRecordsIn": { "min": 0.0, "max": 10.0, "sum": 15.0, "avg": 5.0, 
"skew": 66.0 } } */
+  public loadMetricsWithAllAggregates(
     jobId: string,
     vertexId: string,
-    listOfMetricName: string[],
-    aggregate: string = 'max'
-  ): Observable<MetricMap> {
+    listOfMetricName: string[]
+  ): Observable<MetricMapWithAllAggregates> {
     const metricName = listOfMetricName.join(',');
     return this.httpClient
-      .get<Array<{ id: string; min: number; max: number; avg: number; sum: 
number }>>(
+      .get<Array<{ id: string; min: number; max: number; avg: number; sum: 
number; skew: number }>>(
         
`${this.configService.BASE_URL}/jobs/${jobId}/vertices/${vertexId}/subtasks/metrics`,
         { params: { get: metricName } }
       )
       .pipe(
         map(arr => {
-          const result: MetricMap = {};
+          const result: MetricMapWithAllAggregates = {};
           arr.forEach(item => {
-            switch (aggregate) {
-              case 'min':
-                result[item.id] = +item.min;
-                break;
-              case 'max':
-                result[item.id] = +item.max;
-                break;
-              case 'avg':
-                result[item.id] = +item.avg;
-                break;
-              case 'sum':
-                result[item.id] = +item.sum;
-                break;
-              default:
-                throw new Error(`Unsupported aggregate: ${aggregate}`);
-            }
+            result[item.id] = { min: NaN, max: NaN, avg: NaN, sum: NaN, skew: 
NaN };
+            result[item.id].min = +item.min;
+            result[item.id].max = +item.max;
+            result[item.id].avg = +item.avg;
+            result[item.id].sum = +item.sum;
+            result[item.id].skew = +item.skew;
           });
           return result;
         })
       );
   }
 
+  /** Get metric data from all subtasks of the given vertexId, aggregated by a 
given aggregation type
+  Default aggregation type: max */
+  public loadAggregatedMetrics(
+    jobId: string,
+    vertexId: string,
+    listOfMetricName: string[],
+    aggregate: string = 'max'
+  ): Observable<MetricMap> {
+    const result: MetricMap = {};
+    return this.loadMetricsWithAllAggregates(jobId, vertexId, 
listOfMetricName).pipe(

Review Comment:
   I'm not sure why you think the behaviour has changed.
   
   > all aggregates get loaded, then filtered out to the aggregate we want.
   
   This is the existing behaviour.
   
   This simply refactors out the logic that gets all aggregates. The existing 
method is the same, we now have a new method that **returns** all aggregates 
instead of filtering out to the aggregate we want, which is used here 
https://github.com/apache/flink/pull/24598/files#diff-bbeb39b87fae9c6bb97bd3481f9352fcd5294b005b78d5663b6e9d6f8b807158R168
 note that we use both the max and skew aggregates there.



-- 
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