Skip to content

Commit

Permalink
Don't fail the workflow when failed to emit metrics for one domain (c…
Browse files Browse the repository at this point in the history
…adence-workflow#6640)

* Don't fail the workflow when failed to emit metrics for one domain in ES analyzer

* Return error when all domains fail to emit metrics
  • Loading branch information
neil-xie authored Jan 24, 2025
1 parent 61caf40 commit c30c4a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion service/worker/esanalyzer/domainWorkflowTypeCountWorkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (w *Workflow) emitWorkflowTypeCountMetrics(ctx context.Context) error {
if err != nil {
return err
}
var failedDomains []string
for _, domainName := range workflowMetricDomainNames {
switch w.analyzer.readMode {
case ES:
Expand All @@ -158,9 +159,13 @@ func (w *Workflow) emitWorkflowTypeCountMetrics(ctx context.Context) error {
err = w.emitWorkflowTypeCountMetricsES(ctx, domainName, logger)
}
if err != nil {
return err
logger.Error(fmt.Sprintf("failed to emit workflow type metrics for domain %s", domainName), zap.Error(err))
failedDomains = append(failedDomains, domainName)
}
}
if len(failedDomains) == len(workflowMetricDomainNames) {
return fmt.Errorf("failed to emit workflow type metrics for all domains")
}
}
return nil
}
Expand Down
7 changes: 6 additions & 1 deletion service/worker/esanalyzer/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (w *Workflow) emitWorkflowVersionMetrics(ctx context.Context) error {
if err != nil {
return err
}
var failedDomains []string
for _, domainName := range workflowMetricDomainNames {
switch w.analyzer.readMode {
case ES:
Expand All @@ -207,9 +208,13 @@ func (w *Workflow) emitWorkflowVersionMetrics(ctx context.Context) error {
err = w.emitWorkflowVersionMetricsES(ctx, domainName, logger)
}
if err != nil {
return err
logger.Error(fmt.Sprintf("failed to emit workflow version metrics for domain %s", domainName), zap.Error(err))
failedDomains = append(failedDomains, domainName)
}
}
if len(failedDomains) == len(workflowMetricDomainNames) {
return fmt.Errorf("failed to emit workflow version metrics for all domains")
}
}
return nil
}
Expand Down

0 comments on commit c30c4a8

Please sign in to comment.