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 (#4548)
  • Loading branch information
WToma authored Oct 6, 2021
1 parent 37a8fd7 commit 3cd5166
Show file tree
Hide file tree
Showing 2 changed files with 21 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
15 changes: 15 additions & 0 deletions service/history/execution/context_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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 +114,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 +143,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 3cd5166

Please sign in to comment.