Skip to content

Commit

Permalink
Improve logs for task executor (cadence-workflow#4989)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll authored Sep 6, 2022
1 parent 3362f85 commit c3beb64
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 15 deletions.
15 changes: 15 additions & 0 deletions common/log/tag/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func WorkflowID(workflowID string) Tag {
return newStringTag("wf-id", workflowID)
}

// TargetWorkflowID returns tag for target WorkflowID
func TargetWorkflowID(workflowID string) Tag {
return newStringTag("target-wf-id", workflowID)
}

// WorkflowType returns tag for WorkflowType
func WorkflowType(wfType string) Tag {
return newStringTag("wf-type", wfType)
Expand All @@ -103,6 +108,11 @@ func WorkflowRunID(runID string) Tag {
return newStringTag("wf-run-id", runID)
}

// TargetWorkflowRunID returns tag for target WorkflowRunID
func TargetWorkflowRunID(runID string) Tag {
return newStringTag("target-wf-run-id", runID)
}

// WorkflowResetBaseRunID returns tag for WorkflowResetBaseRunID
func WorkflowResetBaseRunID(runID string) Tag {
return newStringTag("wf-reset-base-run-id", runID)
Expand Down Expand Up @@ -160,6 +170,11 @@ func WorkflowDomainID(domainID string) Tag {
return newStringTag("wf-domain-id", domainID)
}

// TargetWorkflowDomainID returns tag for target WorkflowDomainID
func TargetWorkflowDomainID(domainID string) Tag {
return newStringTag("target-wf-domain-id", domainID)
}

// WorkflowDomainName returns tag for WorkflowDomainName
func WorkflowDomainName(domainName string) Tag {
return newStringTag("wf-domain-name", domainName)
Expand Down
59 changes: 44 additions & 15 deletions service/history/task/transfer_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,14 @@ func (t *transferActiveTaskExecutor) processCancelExecution(
targetDomainName,
requestCancelInfo.CancelRequestID,
); err != nil {
t.logger.Info(fmt.Sprintf("Failed to cancel external workflow execution. Error: %v", err))
t.logger.Error("Failed to cancel external workflow execution",
tag.WorkflowDomainID(task.DomainID),
tag.WorkflowID(task.WorkflowID),
tag.WorkflowRunID(task.RunID),
tag.TargetWorkflowDomainID(task.TargetDomainID),
tag.TargetWorkflowID(task.TargetWorkflowID),
tag.TargetWorkflowRunID(task.TargetRunID),
tag.Error(err))

// Check to see if the error is non-transient, in which case add RequestCancelFailed
// event and complete transfer task by setting the err = nil
Expand All @@ -619,11 +626,13 @@ func (t *transferActiveTaskExecutor) processCancelExecution(
)
}

t.logger.Debug(fmt.Sprintf(
"RequestCancel successfully recorded to external workflow execution. task.WorkflowID: %v, RunID: %v",
task.TargetWorkflowID,
task.TargetRunID,
))
t.logger.Debug("RequestCancel successfully recorded to external workflow execution",
tag.WorkflowDomainID(task.DomainID),
tag.WorkflowID(task.WorkflowID),
tag.WorkflowRunID(task.RunID),
tag.TargetWorkflowDomainID(task.TargetDomainID),
tag.TargetWorkflowID(task.TargetWorkflowID),
tag.TargetWorkflowRunID(task.TargetRunID))

// Record ExternalWorkflowExecutionCancelRequested in source execution
return requestCancelExternalExecutionCompleted(
Expand Down Expand Up @@ -710,7 +719,14 @@ func (t *transferActiveTaskExecutor) processSignalExecution(
targetDomainName,
signalInfo,
); err != nil {
t.logger.Info(fmt.Sprintf("Failed to signal external workflow execution. Error: %v", err))
t.logger.Error("Failed to signal external workflow execution",
tag.WorkflowDomainID(task.DomainID),
tag.WorkflowID(task.WorkflowID),
tag.WorkflowRunID(task.RunID),
tag.TargetWorkflowDomainID(task.TargetDomainID),
tag.TargetWorkflowID(task.TargetWorkflowID),
tag.TargetWorkflowRunID(task.TargetRunID),
tag.Error(err))

// Check to see if the error is non-transient, in which case add SignalFailed
// event and complete transfer task by setting the err = nil
Expand All @@ -730,11 +746,13 @@ func (t *transferActiveTaskExecutor) processSignalExecution(
)
}

t.logger.Debug(fmt.Sprintf(
"Signal successfully recorded to external workflow execution. task.WorkflowID: %v, RunID: %v",
task.TargetWorkflowID,
task.TargetRunID,
))
t.logger.Debug("Signal successfully recorded to external workflow execution",
tag.WorkflowDomainID(task.DomainID),
tag.WorkflowID(task.WorkflowID),
tag.WorkflowRunID(task.RunID),
tag.TargetWorkflowDomainID(task.TargetDomainID),
tag.TargetWorkflowID(task.TargetWorkflowID),
tag.TargetWorkflowRunID(task.TargetRunID))

err = signalExternalExecutionCompleted(
ctx,
Expand Down Expand Up @@ -861,7 +879,13 @@ func (t *transferActiveTaskExecutor) processStartChildExecution(
attributes,
)
if err != nil {
t.logger.Debug(fmt.Sprintf("Failed to start child workflow execution. Error: %v", err))
t.logger.Error("Failed to start child workflow execution",
tag.WorkflowDomainID(task.DomainID),
tag.WorkflowID(task.WorkflowID),
tag.WorkflowRunID(task.RunID),
tag.TargetWorkflowDomainID(task.TargetDomainID),
tag.TargetWorkflowID(attributes.WorkflowID),
tag.Error(err))

// Check to see if the error is non-transient, in which case add StartChildWorkflowExecutionFailed
// event and complete transfer task by setting the err = nil
Expand All @@ -875,8 +899,13 @@ func (t *transferActiveTaskExecutor) processStartChildExecution(
return err
}

t.logger.Debug(fmt.Sprintf("Child Execution started successfully. task.WorkflowID: %v, RunID: %v",
attributes.WorkflowID, childRunID))
t.logger.Debug("Child Execution started successfully",
tag.WorkflowDomainID(task.DomainID),
tag.WorkflowID(task.WorkflowID),
tag.WorkflowRunID(task.RunID),
tag.TargetWorkflowDomainID(task.TargetDomainID),
tag.TargetWorkflowID(attributes.WorkflowID),
tag.TargetWorkflowRunID(childRunID))

// Child execution is successfully started, record ChildExecutionStartedEvent in parent execution
err = recordChildExecutionStarted(ctx, task, wfContext, attributes, childRunID, t.shard.GetTimeSource().Now())
Expand Down

0 comments on commit c3beb64

Please sign in to comment.