diff --git a/common/taskvalidator/validateworkflow.go b/common/taskvalidator/validateworkflow.go index 4a562c2ab14..4871b3c5fb7 100644 --- a/common/taskvalidator/validateworkflow.go +++ b/common/taskvalidator/validateworkflow.go @@ -32,7 +32,7 @@ import ( // Checker is an interface for initiating the validation process. type Checker interface { - WorkflowCheckforValidation(workflowID string, domainID string, runID string) error + WorkflowCheckforValidation(workflowID string, domainID string, domainName string, runID string) error } // checkerImpl is the implementation of the Checker interface. @@ -48,14 +48,16 @@ func NewWfChecker(logger log.Logger, metrics metrics.Client) Checker { } // WorkflowCheckforValidation is a dummy implementation of workflow validation. -func (w *checkerImpl) WorkflowCheckforValidation(workflowID string, domainID string, runID string) error { +func (w *checkerImpl) WorkflowCheckforValidation(workflowID string, domainID string, domainName string, runID string) error { // Emitting just the log to ensure that the workflow is called for now. // TODO: add some validations to check the wf for corruptions. w.logger.Info("WorkflowCheckforValidation", tag.WorkflowID(workflowID), tag.WorkflowRunID(runID), - tag.WorkflowDomainID(domainID)) - // Emit the number of workflows that have come in for the validation. - w.metricsClient.Scope(metrics.TaskValidatorScope).IncCounter(metrics.ValidatedWorkflowCount) + tag.WorkflowDomainID(domainID), + tag.WorkflowDomainName(domainName)) + // Emit the number of workflows that have come in for the validation. Including the domain tag. + // The domain name will be useful when I introduce a flipr switch to turn on validation. + w.metricsClient.Scope(metrics.TaskValidatorScope, metrics.DomainTag(domainName)).IncCounter(metrics.ValidatedWorkflowCount) return nil } diff --git a/common/taskvalidator/validateworkflow_test.go b/common/taskvalidator/validateworkflow_test.go index 304f25ef6c2..9a0d27f62a3 100644 --- a/common/taskvalidator/validateworkflow_test.go +++ b/common/taskvalidator/validateworkflow_test.go @@ -26,6 +26,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/uber/cadence/common/log" "github.com/uber/cadence/common/metrics" ) @@ -47,12 +48,11 @@ func TestWorkflowCheckforValidation(t *testing.T) { workflowID := "testWorkflowID" domainID := "testDomainID" runID := "testRunID" + domainName := "testDomainName" // Call the method being tested - err := checker.WorkflowCheckforValidation(workflowID, domainID, runID) + err := checker.WorkflowCheckforValidation(workflowID, domainID, domainName, runID) // Assert that the method returned no error assert.NoError(t, err) - - // Add additional assertions as needed based on the expected behavior of the method } diff --git a/service/history/handler.go b/service/history/handler.go index 19efc5f530b..c8b7c7735fa 100644 --- a/service/history/handler.go +++ b/service/history/handler.go @@ -31,8 +31,6 @@ import ( "sync/atomic" "time" - "github.com/uber/cadence/service/history/workflow" - "golang.org/x/sync/errgroup" "github.com/uber/cadence/common/membership" @@ -59,6 +57,7 @@ import ( "github.com/uber/cadence/service/history/resource" "github.com/uber/cadence/service/history/shard" "github.com/uber/cadence/service/history/task" + "github.com/uber/cadence/service/history/workflow" ) const shardOwnershipTransferDelay = 5 * time.Second @@ -2236,7 +2235,11 @@ func (h *handlerImpl) error( // We will delete the workflow or mark the workflow as corrupted. // Placing a dummy call to the function to check the coherency of the design. // The function returns nil error so removing error handling for now. - h.GetTaskValidator().WorkflowCheckforValidation(workflowID, domainID, "") + domainName, err := h.GetDomainCache().GetDomainName(domainID) + if err != nil { + return err + } + h.GetTaskValidator().WorkflowCheckforValidation(workflowID, domainID, domainName, "") } return err }