Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Added metrics for ExecutionLockService, DeciderService and WorkflowEx…
Browse files Browse the repository at this point in the history
…ecutor#decide
  • Loading branch information
aravindanr committed Jul 5, 2022
1 parent 0d6430d commit ddc1bed
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.netflix.conductor.annotations.Trace;
import com.netflix.conductor.annotations.VisibleForTesting;
import com.netflix.conductor.common.metadata.tasks.TaskDef;
import com.netflix.conductor.common.metadata.tasks.TaskType;
Expand Down Expand Up @@ -53,6 +54,7 @@
* workflow or do nothing.
*/
@Service
@Trace
public class DeciderService {

private static final Logger LOGGER = LoggerFactory.getLogger(DeciderService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -416,7 +417,7 @@ public String startWorkflow(
try {
createWorkflow(workflow);
// then decide to see if anything needs to be done as part of the workflow
decide(workflowId);
_decide(workflowId);
Monitors.recordWorkflowStartSuccess(
workflow.getWorkflowName(),
String.valueOf(workflow.getWorkflowVersion()),
Expand Down Expand Up @@ -611,7 +612,7 @@ public void restart(String workflowId, boolean useLatestDefinitions) {
throw e;
}

decide(workflowId);
_decide(workflowId);

updateAndPushParents(workflow, "restarted");
}
Expand Down Expand Up @@ -1240,7 +1241,7 @@ public void updateTask(TaskResult taskResult) {
task.getTaskDefName(), lastDuration, false, task.getStatus());
}

decide(workflowId);
_decide(workflowId);
}

public TaskModel getTask(String taskId) {
Expand Down Expand Up @@ -1270,6 +1271,18 @@ public List<String> getRunningWorkflowIds(String workflowName, int version) {
return executionDAOFacade.getRunningWorkflowIds(workflowName, version);
}

/** Records a metric for the "decide" process. */
private boolean _decide(String workflowId) {
StopWatch watch = new StopWatch();
watch.start();
try {
return decide(workflowId);
} finally {
watch.stop();
Monitors.recordWorkflowDecisionTime(watch.getTime());
}
}

/**
* @param workflowId ID of the workflow to evaluate the state for
* @return true if the workflow has completed (success or failed), false otherwise.
Expand Down Expand Up @@ -1521,7 +1534,7 @@ public void resumeWorkflow(String workflowId) {
workflow.getPriority(),
properties.getWorkflowOffsetTimeout().getSeconds());
executionDAOFacade.updateWorkflow(workflow);
decide(workflowId);
_decide(workflowId);
}

/**
Expand Down Expand Up @@ -1588,7 +1601,7 @@ public void skipTaskFromWorkflow(
taskToBeSkipped.setOutputMessage(skipTaskRequest.getTaskOutputMessage());
}
executionDAOFacade.createTasks(Collections.singletonList(taskToBeSkipped));
decide(workflowId);
_decide(workflowId);
}

public WorkflowModel getWorkflow(String workflowId, boolean includeTasks) {
Expand Down Expand Up @@ -1859,7 +1872,7 @@ private boolean rerunWF(
properties.getWorkflowOffsetTimeout().getSeconds());
executionDAOFacade.updateWorkflow(workflow);

decide(workflowId);
_decide(workflowId);
return true;
}

Expand Down Expand Up @@ -1945,7 +1958,7 @@ private boolean rerunWF(
}
executionDAOFacade.updateTask(rerunFromTask);

decide(workflowId);
_decide(workflowId);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ public static void recordTaskExecutionTime(
.record(duration, TimeUnit.MILLISECONDS);
}

public static void recordWorkflowDecisionTime(long duration) {
getTimer(classQualifier, "workflow_decision").record(duration, TimeUnit.MILLISECONDS);
}

public static void recordTaskPollError(String taskType, String exception) {
recordTaskPollError(taskType, NO_DOMAIN, exception);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netflix.conductor.annotations.Trace;
import com.netflix.conductor.core.config.ConductorProperties;
import com.netflix.conductor.core.sync.Lock;
import com.netflix.conductor.metrics.Monitors;

@Service
@Trace
public class ExecutionLockService {

private static final Logger LOGGER = LoggerFactory.getLogger(ExecutionLockService.class);
Expand Down

0 comments on commit ddc1bed

Please sign in to comment.