Skip to content

Commit

Permalink
Fix task_skipped metrics tag inconsistency (#6712)
Browse files Browse the repository at this point in the history
## What changed?
Add NamespaceTag and TaskTypeTag to task_skipped metric. These two tags
are emitted from executable.go. This is causing a metrics tag
inconsistency during namespace handover.

## Why?
Fix metrics tag inconsistency.

## How did you test it?

## Potential risks

## Documentation

## Is hotfix candidate?
None
  • Loading branch information
prathyushpv authored Oct 24, 2024
1 parent bdd1b10 commit d171043
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion service/history/ndc_task_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/service/history/consts"
"go.temporal.io/server/service/history/queues"
"go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/tasks"
"go.temporal.io/server/service/history/vclock"
Expand Down Expand Up @@ -94,6 +95,7 @@ func loadMutableStateForTransferTask(
tasks.GetTransferTaskEventID,
transferTaskMutableStateStaleChecker,
metricsHandler.WithTags(metrics.OperationTag(metrics.OperationTransferQueueProcessorScope)),
queues.GetActiveTransferTaskTypeTagValue(transferTask),
logger,
)
if err != nil {
Expand Down Expand Up @@ -141,6 +143,7 @@ func loadMutableStateForTimerTask(
tasks.GetTimerTaskEventID,
timerTaskMutableStateStaleChecker,
metricsHandler.WithTags(metrics.OperationTag(metrics.OperationTimerQueueProcessorScope)),
queues.GetActiveTimerTaskTypeTagValue(timerTask),
logger,
)
}
Expand All @@ -153,6 +156,7 @@ func loadMutableStateForTask(
getEventID taskEventIDGetter,
canMutableStateBeStale mutableStateStaleChecker,
metricsHandler metrics.Handler,
taskTypeTag string,
logger log.Logger,
) (workflow.MutableState, error) {

Expand Down Expand Up @@ -209,7 +213,8 @@ func loadMutableStateForTask(
}
// After reloading mutable state from a database, task's event ID is still not valid,
// means that task is obsolete and can be safely skipped.
metrics.TaskSkipped.With(metricsHandler).Record(1)
getNamespaceTagByID(shardContext.GetNamespaceRegistry(), task.GetNamespaceID())
metrics.TaskSkipped.With(metricsHandler).Record(1, getNamespaceTagByID(shardContext.GetNamespaceRegistry(), task.GetNamespaceID()), metrics.TaskTypeTag(taskTypeTag))
logger.Info("Task processor skipping task: task event ID >= MS NextEventID.",
tag.WorkflowNextEventID(mutableState.GetNextEventID()),
)
Expand Down
5 changes: 2 additions & 3 deletions service/history/queues/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ func GetStandbyTransferTaskTypeTagValue(
}

func GetActiveTimerTaskTypeTagValue(
executable Executable,
task tasks.Task,
) string {
task := executable.GetTask()
switch t := task.(type) {
case *tasks.WorkflowTaskTimeoutTask:
if t.InMemory {
Expand Down Expand Up @@ -207,7 +206,7 @@ func getTaskTypeTagValue(
return GetStandbyTransferTaskTypeTagValue(task)
case tasks.CategoryTimer:
if isActive {
return GetActiveTimerTaskTypeTagValue(executable)
return GetActiveTimerTaskTypeTagValue(task)
}
return GetStandbyTimerTaskTypeTagValue(task)
case tasks.CategoryVisibility:
Expand Down
2 changes: 1 addition & 1 deletion service/history/timer_queue_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (t *timerQueueActiveTaskExecutor) Execute(
ctx context.Context,
executable queues.Executable,
) queues.ExecuteResponse {
taskTypeTagValue := queues.GetActiveTimerTaskTypeTagValue(executable)
taskTypeTagValue := queues.GetActiveTimerTaskTypeTagValue(executable.GetTask())

namespaceTag, replicationState := getNamespaceTagAndReplicationStateByID(
t.shardContext.GetNamespaceRegistry(),
Expand Down

0 comments on commit d171043

Please sign in to comment.