From c3beb64890fc7aefc1d0956fd6c59e07e4abfd4b Mon Sep 17 00:00:00 2001 From: Zijian Date: Tue, 6 Sep 2022 08:59:27 -0700 Subject: [PATCH] Improve logs for task executor (#4989) --- common/log/tag/tags.go | 15 +++++ .../task/transfer_active_task_executor.go | 59 ++++++++++++++----- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/common/log/tag/tags.go b/common/log/tag/tags.go index 71f60a01d7c..e5ceb2b06ef 100644 --- a/common/log/tag/tags.go +++ b/common/log/tag/tags.go @@ -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) @@ -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) @@ -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) diff --git a/service/history/task/transfer_active_task_executor.go b/service/history/task/transfer_active_task_executor.go index 4736bfb35a1..812bba487db 100644 --- a/service/history/task/transfer_active_task_executor.go +++ b/service/history/task/transfer_active_task_executor.go @@ -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 @@ -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( @@ -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 @@ -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, @@ -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 @@ -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())