Skip to content

Commit

Permalink
bugfix: workflow already started error metrics is not handled correct…
Browse files Browse the repository at this point in the history
…ly (cadence-workflow#518)

* bugfix: workflow already started error metrics is not handled correctly
  • Loading branch information
wxing1292 authored Jan 22, 2018
1 parent bd9eb9f commit 6ce4fdc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/persistence/persistenceMetricClients.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (p *workflowExecutionPersistenceClient) CompleteTimerTask(request *Complete

func (p *workflowExecutionPersistenceClient) updateErrorMetric(scope int, err error) {
switch err.(type) {
case *workflow.WorkflowExecutionAlreadyStartedError:
case *WorkflowExecutionAlreadyStartedError:
p.metricClient.IncCounter(scope, metrics.CadenceErrExecutionAlreadyStartedCounter)
case *ShardOwnershipLostError:
p.metricClient.IncCounter(scope, metrics.PersistenceErrShardOwnershipLostCounter)
Expand Down
2 changes: 2 additions & 0 deletions service/history/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ func (h *Handler) updateErrorMetric(scope int, err error) {
h.metricsClient.IncCounter(scope, metrics.CadenceErrEventAlreadyStartedCounter)
case *gen.BadRequestError:
h.metricsClient.IncCounter(scope, metrics.CadenceErrBadRequestCounter)
case *gen.WorkflowExecutionAlreadyStartedError:
h.metricsClient.IncCounter(scope, metrics.CadenceErrExecutionAlreadyStartedCounter)
case *gen.EntityNotExistsError:
h.metricsClient.IncCounter(scope, metrics.CadenceErrEntityNotExistsCounter)
case *gen.CancellationAlreadyRequestedError:
Expand Down
12 changes: 9 additions & 3 deletions service/history/historyEngine2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,9 @@ func (s *engine2Suite) TestStartWorkflowExecution_StillRunning_NonDeDup() {
RequestId: common.StringPtr("newRequestID"),
},
})
s.NotNil(err)
if _, ok := err.(*workflow.WorkflowExecutionAlreadyStartedError); !ok {
s.Fail("return err is not *shared.WorkflowExecutionAlreadyStartedError")
}
s.Nil(resp)
}

Expand Down Expand Up @@ -848,7 +850,9 @@ func (s *engine2Suite) TestStartWorkflowExecution_NotRunning_PrevSuccess() {
})

if expecedErrs[index] {
s.NotNil(err)
if _, ok := err.(*workflow.WorkflowExecutionAlreadyStartedError); !ok {
s.Fail("return err is not *shared.WorkflowExecutionAlreadyStartedError")
}
s.Nil(resp)
} else {
s.Nil(err)
Expand Down Expand Up @@ -922,7 +926,9 @@ func (s *engine2Suite) TestStartWorkflowExecution_NotRunning_PrevFail() {
})

if expecedErrs[j] {
s.NotNil(err)
if _, ok := err.(*workflow.WorkflowExecutionAlreadyStartedError); !ok {
s.Fail("return err is not *shared.WorkflowExecutionAlreadyStartedError")
}
s.Nil(resp)
} else {
s.Nil(err)
Expand Down

0 comments on commit 6ce4fdc

Please sign in to comment.