Skip to content

Commit

Permalink
Log WorkflowID, RunID, domainName when a workflow times out or gets t…
Browse files Browse the repository at this point in the history
…erminated
  • Loading branch information
Tamas Weisz committed Oct 6, 2021
1 parent 37a8fd7 commit 3ae75d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions service/history/execution/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ func (c *contextImpl) ConflictResolveWorkflowExecution(
if event, err := resetMutableState.GetCompletionEvent(ctx); err == nil {
workflowType := resetWorkflow.ExecutionInfo.WorkflowTypeName
taskList := resetWorkflow.ExecutionInfo.TaskList
emitWorkflowCompletionStats(c.metricsClient, domainName, workflowType, taskList, event)
emitWorkflowCompletionStats(c.metricsClient, c.logger,
domainName, workflowType, c.workflowExecution.GetWorkflowID(), c.workflowExecution.GetRunID(),
taskList, event)
}
}

Expand Down Expand Up @@ -754,7 +756,9 @@ func (c *contextImpl) UpdateWorkflowExecutionWithNew(
if event, err := c.mutableState.GetCompletionEvent(ctx); err == nil {
workflowType := currentWorkflow.ExecutionInfo.WorkflowTypeName
taskList := currentWorkflow.ExecutionInfo.TaskList
emitWorkflowCompletionStats(c.metricsClient, domainName, workflowType, taskList, event)
emitWorkflowCompletionStats(c.metricsClient, c.logger,
domainName, workflowType, c.workflowExecution.GetWorkflowID(), c.workflowExecution.GetRunID(),
taskList, event)
}
}

Expand Down
16 changes: 16 additions & 0 deletions service/history/execution/context_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ package execution
import (
"time"

"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/log/tag"

"github.com/uber/cadence/common/metrics"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
Expand Down Expand Up @@ -112,8 +115,11 @@ func emitSessionUpdateStats(

func emitWorkflowCompletionStats(
metricsClient metrics.Client,
logger log.Logger,
domainName string,
workflowType string,
workflowID string,
runID string,
taskList string,
event *types.HistoryEvent,
) {
Expand All @@ -138,7 +144,17 @@ func emitWorkflowCompletionStats(
scope.IncCounter(metrics.WorkflowFailedCount)
case types.EventTypeWorkflowExecutionTimedOut:
scope.IncCounter(metrics.WorkflowTimeoutCount)
logger.Info("workflow execution timed out",
tag.WorkflowID(workflowID),
tag.WorkflowRunID(runID),
tag.WorkflowDomainName(domainName),
)
case types.EventTypeWorkflowExecutionTerminated:
scope.IncCounter(metrics.WorkflowTerminateCount)
logger.Info("workflow terminated",
tag.WorkflowID(workflowID),
tag.WorkflowRunID(runID),
tag.WorkflowDomainName(domainName),
)
}
}

0 comments on commit 3ae75d0

Please sign in to comment.