Skip to content

Commit

Permalink
Add tasklist type tag for all metrics from tasklistmgr scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll committed Jul 20, 2024
1 parent 4a51fb4 commit eba09fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions service/matching/handler/engine_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ func (s *matchingEngineSuite) SyncMatchTasks(taskType int, enableIsolation bool)
s.True(expectedRange <= s.taskManager.GetRangeID(testParam.TaskListID))

if throttledTaskCount > 0 {
syncCtr := scope.Snapshot().Counters()["test.sync_throttle_count_per_tl+domain="+matchingTestDomainName+",operation=TaskListMgr,tasklist="+testParam.TaskList.Name]
syncCtr := scope.Snapshot().Counters()["test.sync_throttle_count_per_tl+domain="+matchingTestDomainName+",operation=TaskListMgr,tasklist="+testParam.TaskList.Name+",tasklistType=activity"]
s.EqualValues(throttledTaskCount, int(syncCtr.Value()))
}

Expand Down Expand Up @@ -790,8 +790,8 @@ func (s *matchingEngineSuite) ConcurrentAddAndPollTasks(taskType int, workerCoun
mgr.Stop()
s.EqualValues(0, s.taskManager.GetTaskCount(testParam.TaskListID))

syncCtr := scope.Snapshot().Counters()["test.sync_throttle_count_per_tl+domain="+matchingTestDomainName+",operation=TaskListMgr,tasklist="+testParam.TaskList.Name]
bufCtr := scope.Snapshot().Counters()["test.buffer_throttle_count_per_tl+domain="+matchingTestDomainName+",operation=TaskListMgr,tasklist="+testParam.TaskList.Name]
syncCtr := scope.Snapshot().Counters()["test.sync_throttle_count_per_tl+domain="+matchingTestDomainName+",operation=TaskListMgr,tasklist="+testParam.TaskList.Name+",tasklistType=activity"]
bufCtr := scope.Snapshot().Counters()["test.buffer_throttle_count_per_tl+domain="+matchingTestDomainName+",operation=TaskListMgr,tasklist="+testParam.TaskList.Name+",tasklistType=activity"]
total := int64(0)
if syncCtr != nil {
total += syncCtr.Value()
Expand Down
8 changes: 3 additions & 5 deletions service/matching/tasklist/task_list_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ func NewManager(
taskListKind = &normalTaskListKind
}

scope := NewPerTaskListScope(domainName, taskList.GetName(), *taskListKind, metricsClient, metrics.MatchingTaskListMgrScope)
scope := NewPerTaskListScope(domainName, taskList.GetName(), *taskListKind, metricsClient, metrics.MatchingTaskListMgrScope).
Tagged(getTaskListTypeTag(taskList.GetType()))
db := newTaskListDB(taskManager, taskList.GetDomainID(), domainName, taskList.GetName(), taskList.GetType(), int(*taskListKind), logger)

tlMgr := &taskListManagerImpl{
Expand All @@ -177,11 +178,8 @@ func NewManager(
closeCallback: closeCallback,
}

taskListTypeMetricScope := tlMgr.scope.Tagged(
getTaskListTypeTag(taskList.GetType()),
)
tlMgr.pollerHistory = poller.NewPollerHistory(func() {
taskListTypeMetricScope.UpdateGauge(metrics.PollerPerTaskListCounter,
scope.UpdateGauge(metrics.PollerPerTaskListCounter,
float64(len(tlMgr.pollerHistory.GetPollerInfo(time.Time{}))))
}, timeSource)

Expand Down
9 changes: 3 additions & 6 deletions service/matching/tasklist/task_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ getTasksPumpLoop:
{
ackLevel := tr.taskAckManager.GetAckLevel()
if size, err := tr.db.GetTaskListSize(ackLevel); err == nil {
tr.scope.Tagged(getTaskListTypeTag(tr.taskListID.GetType())).
UpdateGauge(metrics.TaskCountPerTaskListGauge, float64(size))
tr.scope.UpdateGauge(metrics.TaskCountPerTaskListGauge, float64(size))

Check warning on line 223 in service/matching/tasklist/task_reader.go

View check run for this annotation

Codecov / codecov/patch

service/matching/tasklist/task_reader.go#L223

Added line #L223 was not covered by tests
}
if err := tr.handleErr(tr.persistAckLevel()); err != nil {
tr.logger.Error("Persistent store operation failure",
Expand All @@ -233,8 +232,7 @@ getTasksPumpLoop:
updateAckTimer = time.NewTimer(tr.config.UpdateAckInterval())
}
}
scope := tr.scope.Tagged(getTaskListTypeTag(tr.taskListID.GetType()))
scope.UpdateGauge(metrics.TaskBacklogPerTaskListGauge, float64(tr.taskAckManager.GetBacklogCount()))
tr.scope.UpdateGauge(metrics.TaskBacklogPerTaskListGauge, float64(tr.taskAckManager.GetBacklogCount()))
}
}

Expand Down Expand Up @@ -334,10 +332,9 @@ func (tr *taskReader) persistAckLevel() error {
ackLevel := tr.taskAckManager.GetAckLevel()
if ackLevel >= 0 {
maxReadLevel := tr.taskWriter.GetMaxReadLevel()
scope := tr.scope.Tagged(getTaskListTypeTag(tr.taskListID.GetType()))
// note: this metrics is only an estimation for the lag. taskID in DB may not be continuous,
// especially when task list ownership changes.
scope.UpdateGauge(metrics.TaskLagPerTaskListGauge, float64(maxReadLevel-ackLevel))
tr.scope.UpdateGauge(metrics.TaskLagPerTaskListGauge, float64(maxReadLevel-ackLevel))

return tr.db.UpdateState(ackLevel)
}
Expand Down

0 comments on commit eba09fc

Please sign in to comment.