gyfora commented on code in PR #726: URL: https://github.com/apache/flink-kubernetes-operator/pull/726#discussion_r1425246326
########## flink-autoscaler/src/main/java/org/apache/flink/autoscaler/RestApiMetricsCollector.java: ########## @@ -78,19 +99,89 @@ protected Map<FlinkMetric, AggregatedMetric> queryAggregatedVertexMetrics( EmptyRequestBody.getInstance()) .get(); - return responseBody.getMetrics().stream() - .collect( - Collectors.toMap( - m -> metrics.get(m.getId()), - m -> m, - (m1, m2) -> - new AggregatedMetric( - m1.getId() + " merged with " + m2.getId(), - Math.min(m1.getMin(), m2.getMin()), - Math.max(m1.getMax(), m2.getMax()), - // Average can't be computed - Double.NaN, - m1.getSum() + m2.getSum()))); + return aggregateByFlinkMetric(metrics, responseBody); } } + + protected Map<FlinkMetric, AggregatedMetric> queryTmMetrics(Context ctx) throws Exception { + try (var restClient = ctx.getRestClusterClient()) { + boolean hasGcMetrics = + jobsWithGcMetrics.computeIfAbsent( + ctx.getJobKey(), + k -> { + boolean gcMetricsFound = + !queryAggregatedTmMetrics( + restClient, TM_METRIC_NAMES_WITH_GC) + .isEmpty(); Review Comment: That’s not how this works unfortunately, if any of the metrics is not found an empty response comes back from Flink ########## flink-autoscaler/src/main/java/org/apache/flink/autoscaler/RestApiMetricsCollector.java: ########## @@ -78,19 +99,89 @@ protected Map<FlinkMetric, AggregatedMetric> queryAggregatedVertexMetrics( EmptyRequestBody.getInstance()) .get(); - return responseBody.getMetrics().stream() - .collect( - Collectors.toMap( - m -> metrics.get(m.getId()), - m -> m, - (m1, m2) -> - new AggregatedMetric( - m1.getId() + " merged with " + m2.getId(), - Math.min(m1.getMin(), m2.getMin()), - Math.max(m1.getMax(), m2.getMax()), - // Average can't be computed - Double.NaN, - m1.getSum() + m2.getSum()))); + return aggregateByFlinkMetric(metrics, responseBody); } } + + protected Map<FlinkMetric, AggregatedMetric> queryTmMetrics(Context ctx) throws Exception { + try (var restClient = ctx.getRestClusterClient()) { + boolean hasGcMetrics = + jobsWithGcMetrics.computeIfAbsent( + ctx.getJobKey(), + k -> { + boolean gcMetricsFound = + !queryAggregatedTmMetrics( + restClient, TM_METRIC_NAMES_WITH_GC) + .isEmpty(); Review Comment: That’s not how this works unfortunately, if any of the metrics is not found an empty response comes back from Flink -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org