Skip to content

Commit

Permalink
Fix task executable metrics tags (#3307)
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Sep 7, 2022
1 parent 25c2594 commit ba13e73
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions service/history/queues/executable.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func NewExecutable(
},
),
metricsHandler: metricsHandler,
taggedMetricsHandler: metricsHandler,
criticalRetryAttempt: criticalRetryAttempt,
filter: filter,
namespaceCacheRefreshInterval: namespaceCacheRefreshInterval,
Expand Down Expand Up @@ -232,7 +233,7 @@ func (e *executableImpl) HandleErr(err error) (retErr error) {

e.attempt++
if e.attempt > e.criticalRetryAttempt() {
e.metricsHandler.Histogram(TaskAttempt, metrics.Dimensionless).Record(int64(e.attempt))
e.taggedMetricsHandler.Histogram(TaskAttempt, metrics.Dimensionless).Record(int64(e.attempt))
e.logger.Error("Critical error processing task, retrying.", tag.Error(err), tag.OperationCritical)
}

Expand All @@ -258,17 +259,17 @@ func (e *executableImpl) HandleErr(err error) (retErr error) {
}

if err == consts.ErrTaskRetry {
e.metricsHandler.Counter(TaskStandbyRetryCounter).Record(1)
e.taggedMetricsHandler.Counter(TaskStandbyRetryCounter).Record(1)
return err
}

if err == consts.ErrWorkflowBusy {
e.metricsHandler.Counter(TaskWorkflowBusyCounter).Record(1)
e.taggedMetricsHandler.Counter(TaskWorkflowBusyCounter).Record(1)
return err
}

if err == consts.ErrTaskDiscarded {
e.metricsHandler.Counter(TaskDiscarded).Record(1)
e.taggedMetricsHandler.Counter(TaskDiscarded).Record(1)
return nil
}

Expand All @@ -277,14 +278,14 @@ func (e *executableImpl) HandleErr(err error) (retErr error) {
// since the new task life cycle will not give up until task processed / verified
if _, ok := err.(*serviceerror.NamespaceNotActive); ok {
if e.timeSource.Now().Sub(e.loadTime) > 2*e.namespaceCacheRefreshInterval() {
e.metricsHandler.Counter(TaskNotActiveCounter).Record(1)
e.taggedMetricsHandler.Counter(TaskNotActiveCounter).Record(1)
return nil
}

return err
}

e.metricsHandler.Counter(TaskFailures).Record(1)
e.taggedMetricsHandler.Counter(TaskFailures).Record(1)

e.logger.Error("Fail to process task", tag.Error(err), tag.LifeCycleProcessingFailed)
return err
Expand Down

0 comments on commit ba13e73

Please sign in to comment.