From f9f1fe10588b707ad33ef0b58c091f48d7c398e5 Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Thu, 30 Jan 2025 13:06:43 -0800 Subject: [PATCH 1/2] Sampling on emitting misconfigured partition metrics --- service/matching/tasklist/task_list_manager.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service/matching/tasklist/task_list_manager.go b/service/matching/tasklist/task_list_manager.go index ba968a1d563..96158fef054 100644 --- a/service/matching/tasklist/task_list_manager.go +++ b/service/matching/tasklist/task_list_manager.go @@ -27,6 +27,7 @@ import ( "context" "errors" "fmt" + "math/rand/v2" "reflect" "sort" "sync" @@ -63,6 +64,8 @@ const ( returnEmptyTaskTimeBudget = time.Second noIsolationTimeout = time.Duration(0) minimumIsolationDuration = time.Millisecond * 50 + // sampling rate for emitting misconfigured partition metrics + misconfiguredPartitionEmitRate = 0.05 ) var ( @@ -643,7 +646,9 @@ func (c *taskListManagerImpl) GetTask( } func (c *taskListManagerImpl) getTask(ctx context.Context, maxDispatchPerSecond *float64) (*InternalTask, error) { - c.emitMisconfiguredPartitionMetrics() + if rand.Float32() < misconfiguredPartitionEmitRate { + c.emitMisconfiguredPartitionMetrics() + } // We need to set a shorter timeout than the original ctx; otherwise, by the time ctx deadline is // reached, instead of emptyTask, context timeout error is returned to the frontend by the rpc stack, // which counts against our SLO. By shortening the timeout by a very small amount, the emptyTask can be From c202eb73d54484494d57f08ee5e6630349508690 Mon Sep 17 00:00:00 2001 From: Shijie Sheng Date: Thu, 30 Jan 2025 13:40:47 -0800 Subject: [PATCH 2/2] lint --- service/matching/tasklist/task_list_manager.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/matching/tasklist/task_list_manager.go b/service/matching/tasklist/task_list_manager.go index 96158fef054..854adc50e4e 100644 --- a/service/matching/tasklist/task_list_manager.go +++ b/service/matching/tasklist/task_list_manager.go @@ -27,7 +27,6 @@ import ( "context" "errors" "fmt" - "math/rand/v2" "reflect" "sort" "sync" @@ -36,6 +35,7 @@ import ( "golang.org/x/exp/maps" "golang.org/x/sync/errgroup" + "math/rand/v2" "github.com/uber/cadence/client/history" "github.com/uber/cadence/client/matching"