private void instrumentAlert(WorkflowExecutionContext context) { String clusterName = context.getClusterName(); String entityName = context.getEntityName(); String entityType = context.getEntityType(); String operation = context.getOperation().name(); String workflowId = context.getWorkflowId(); String workflowUser = context.getWorkflowUser(); String nominalTime = context.getNominalTimeAsISO8601(); String runId = String.valueOf(context.getWorkflowRunId()); Date now = new Date(); // Start and/or End time may not be set in case of workflow suspend Date endTime; if (context.getWorkflowEndTime() == 0) { endTime = now; } else { endTime = new Date(context.getWorkflowEndTime()); } Date startTime; if (context.getWorkflowStartTime() == 0) { startTime = now; } else { startTime = new Date(context.getWorkflowStartTime()); } Long duration = (endTime.getTime() - startTime.getTime()) * 1000000; if (context.hasWorkflowFailed()) { GenericAlert.instrumentFailedInstance( clusterName, entityType, entityName, nominalTime, workflowId, workflowUser, runId, operation, SchemaHelper.formatDateUTC(startTime), "", "", duration); } else { GenericAlert.instrumentSucceededInstance( clusterName, entityType, entityName, nominalTime, workflowId, workflowUser, runId, operation, SchemaHelper.formatDateUTC(startTime), duration); } }