You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/06/30 08:42:50 UTC

[GitHub] [flink] xintongsong commented on a diff in pull request #20111: [FLINK-28309][rest] Introduce metrics of the duration that a task sta…

xintongsong commented on code in PR #20111:
URL: https://github.com/apache/flink/pull/20111#discussion_r910765394


##########
flink-runtime/src/main/java/org/apache/flink/runtime/rest/messages/job/SubtaskExecutionAttemptDetailsInfo.java:
##########
@@ -237,6 +256,57 @@ public static SubtaskExecutionAttemptDetailsInfo create(
                 endTime,
                 duration,
                 ioMetricsInfo,
-                taskmanagerId);
+                taskmanagerId,
+                getExecutionStateDuration(execution));
+    }
+
+    private static Map<ExecutionState, Long> getExecutionStateDuration(AccessExecution execution) {
+        Map<ExecutionState, Long> executionStateDuration = new HashMap<>();
+        long now = System.currentTimeMillis();
+        ExecutionState state = execution.getState();
+        executionStateDuration.put(
+                ExecutionState.CREATED,
+                calculateStateDuration(
+                        execution.getStateTimestamp(ExecutionState.CREATED),
+                        execution.getStateEndTimestamp(ExecutionState.CREATED),
+                        state == ExecutionState.CREATED ? now : 0));

Review Comment:
   ```suggestion
           executionStateDuration.put(
                   ExecutionState.CREATED,
                   calculateStateDuration(
                           execution.getStateTimestamp(ExecutionState.CREATED),
                           state == ExecutionState.CREATED ? now : execution.getStateEndTimestamp(ExecutionState.CREATED)));
   ```
   
   I think this helps prevent the implicity that indicating the current state with `now != 0`.



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org