arjun4084346 commented on code in PR #3532:
URL: https://github.com/apache/gobblin/pull/3532#discussion_r936056633


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManager.java:
##########
@@ -1132,24 +1035,39 @@ private void cleanUp() {
           DagNode<JobExecutionPlan> dagNode = dagNodeList.poll();
           deleteJobState(dagId, dagNode);
         }
-        log.info("Dag {} has finished with status FAILED; Cleaning up dag from 
the state store.", dagId);
-        onFlowFailure(dagId);
+        Dag<JobExecutionPlan> dag = this.dags.get(dagId);
+        String status = TimingEvent.FlowTimings.FLOW_FAILED;
+        if 
(TimingEvent.FlowTimings.FLOW_RUN_DEADLINE_EXCEEDED.equals(dag.getFlowEvent())) 
{
+          
this.dagManagerMetrics.emitFlowSlaExceededMetrics(DagManagerUtils.getFlowId(dag));
+        } else if 
(!TimingEvent.FlowTimings.FLOW_START_DEADLINE_EXCEEDED.equals(dag.getFlowEvent()))
 {
+          
dagManagerMetrics.emitFlowFailedMetrics(DagManagerUtils.getFlowId(this.dags.get(dagId)));
+        }
+        addFailedDag(dagId);
+        log.info("Dag {} has finished with status {}; Cleaning up dag from the 
state store.", dagId, status);
         // send an event before cleaning up dag
-        DagManagerUtils.emitFlowEvent(this.eventSubmitter, 
this.dags.get(dagId), TimingEvent.FlowTimings.FLOW_FAILED);
+        DagManagerUtils.emitFlowEvent(this.eventSubmitter, 
this.dags.get(dagId), status);
         dagIdstoClean.add(dagId);
       }
 
-      //Clean up completed dags
-      for (String dagId : this.dags.keySet()) {
+      // Remove dags that are finished and emit their appropriate metrics
+      for (Map.Entry<String, Dag<JobExecutionPlan>> dagIdKeyPair : 
this.dags.entrySet()) {
+        String dagId = dagIdKeyPair.getKey();
+        Dag<JobExecutionPlan> dag = dagIdKeyPair.getValue();
         if (!hasRunningJobs(dagId) && 
!this.failedDagIdsFinishRunning.contains(dagId)) {
           String status = TimingEvent.FlowTimings.FLOW_SUCCEEDED;
           if (this.failedDagIdsFinishAllPossible.contains(dagId)) {
-            onFlowFailure(dagId);
+            if 
(TimingEvent.FlowTimings.FLOW_RUN_DEADLINE_EXCEEDED.equals(dag.getFlowEvent())) 
{

Review Comment:
   Are we sure we want to decouple `addFailedDag` and metrics emission?



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