From d7fb8a9e87e2e92357d71f5f0a1c2370eccdc451 Mon Sep 17 00:00:00 2001 From: okJiang <819421878@qq.com> Date: Mon, 15 Jul 2024 14:23:28 +0800 Subject: [PATCH] add scheduler type and move metrics Signed-off-by: okJiang <819421878@qq.com> --- pkg/schedule/schedulers/balance_leader.go | 11 -- pkg/schedule/schedulers/balance_region.go | 12 -- pkg/schedule/schedulers/evict_leader.go | 9 - pkg/schedule/schedulers/evict_slow_store.go | 3 - pkg/schedule/schedulers/grant_hot_region.go | 6 - pkg/schedule/schedulers/grant_leader.go | 7 - pkg/schedule/schedulers/hot_region.go | 38 ---- pkg/schedule/schedulers/label.go | 9 - pkg/schedule/schedulers/metrics.go | 182 +++++++++++++++++- pkg/schedule/schedulers/random_merge.go | 10 - pkg/schedule/schedulers/scatter_range.go | 10 - pkg/schedule/schedulers/shuffle_hot_region.go | 7 - pkg/schedule/schedulers/shuffle_leader.go | 8 - pkg/schedule/schedulers/shuffle_region.go | 10 - pkg/schedule/schedulers/split_bucket.go | 14 -- .../schedulers/transfer_witness_leader.go | 7 - pkg/schedule/type/type.go | 36 ++++ 17 files changed, 217 insertions(+), 162 deletions(-) diff --git a/pkg/schedule/schedulers/balance_leader.go b/pkg/schedule/schedulers/balance_leader.go index c4b9cd6ab5e..80755fbdbe5 100644 --- a/pkg/schedule/schedulers/balance_leader.go +++ b/pkg/schedule/schedulers/balance_leader.go @@ -55,17 +55,6 @@ const ( transferOut = "transfer-out" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - balanceLeaderScheduleCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "schedule") - balanceLeaderNoLeaderRegionCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "no-leader-region") - balanceLeaderRegionHotCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "region-hot") - balanceLeaderNoTargetStoreCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "no-target-store") - balanceLeaderNoFollowerRegionCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "no-follower-region") - balanceLeaderSkipCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "skip") - balanceLeaderNewOpCounter = schedulerCounter.WithLabelValues(BalanceLeaderName, "new-operator") -) - type balanceLeaderSchedulerConfig struct { syncutil.RWMutex storage endpoint.ConfigStorage diff --git a/pkg/schedule/schedulers/balance_region.go b/pkg/schedule/schedulers/balance_region.go index bfc1a236481..488b7635b77 100644 --- a/pkg/schedule/schedulers/balance_region.go +++ b/pkg/schedule/schedulers/balance_region.go @@ -36,18 +36,6 @@ const ( BalanceRegionType = "balance-region" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - balanceRegionScheduleCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "schedule") - balanceRegionNoRegionCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "no-region") - balanceRegionHotCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "region-hot") - balanceRegionNoLeaderCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "no-leader") - balanceRegionNewOpCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "new-operator") - balanceRegionSkipCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "skip") - balanceRegionCreateOpFailCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "create-operator-fail") - balanceRegionNoReplacementCounter = schedulerCounter.WithLabelValues(BalanceRegionName, "no-replacement") -) - type balanceRegionSchedulerConfig struct { Name string `json:"name"` Ranges []core.KeyRange `json:"ranges"` diff --git a/pkg/schedule/schedulers/evict_leader.go b/pkg/schedule/schedulers/evict_leader.go index 8f56643f384..6cbd04ee671 100644 --- a/pkg/schedule/schedulers/evict_leader.go +++ b/pkg/schedule/schedulers/evict_leader.go @@ -47,15 +47,6 @@ const ( lastStoreDeleteInfo = "The last store has been deleted" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - evictLeaderCounter = schedulerCounter.WithLabelValues(EvictLeaderName, "schedule") - evictLeaderNoLeaderCounter = schedulerCounter.WithLabelValues(EvictLeaderName, "no-leader") - evictLeaderPickUnhealthyCounter = schedulerCounter.WithLabelValues(EvictLeaderName, "pick-unhealthy-region") - evictLeaderNoTargetStoreCounter = schedulerCounter.WithLabelValues(EvictLeaderName, "no-target-store") - evictLeaderNewOperatorCounter = schedulerCounter.WithLabelValues(EvictLeaderName, "new-operator") -) - type evictLeaderSchedulerConfig struct { syncutil.RWMutex storage endpoint.ConfigStorage diff --git a/pkg/schedule/schedulers/evict_slow_store.go b/pkg/schedule/schedulers/evict_slow_store.go index 9b13e292c87..b4cc79e782a 100644 --- a/pkg/schedule/schedulers/evict_slow_store.go +++ b/pkg/schedule/schedulers/evict_slow_store.go @@ -43,9 +43,6 @@ const ( slowStoreRecoverThreshold = 1 ) -// WithLabelValues is a heavy operation, define variable to avoid call it every time. -var evictSlowStoreCounter = schedulerCounter.WithLabelValues(EvictSlowStoreName, "schedule") - type evictSlowStoreSchedulerConfig struct { syncutil.RWMutex cluster *core.BasicCluster diff --git a/pkg/schedule/schedulers/grant_hot_region.go b/pkg/schedule/schedulers/grant_hot_region.go index 4ab82be4cbe..a19a4e1bf4b 100644 --- a/pkg/schedule/schedulers/grant_hot_region.go +++ b/pkg/schedule/schedulers/grant_hot_region.go @@ -47,12 +47,6 @@ const ( GrantHotRegionType = "grant-hot-region" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - grantHotRegionCounter = schedulerCounter.WithLabelValues(GrantHotRegionName, "schedule") - grantHotRegionSkipCounter = schedulerCounter.WithLabelValues(GrantHotRegionName, "skip") -) - type grantHotRegionSchedulerConfig struct { syncutil.RWMutex storage endpoint.ConfigStorage diff --git a/pkg/schedule/schedulers/grant_leader.go b/pkg/schedule/schedulers/grant_leader.go index 4752ef3e61d..21900fac85d 100644 --- a/pkg/schedule/schedulers/grant_leader.go +++ b/pkg/schedule/schedulers/grant_leader.go @@ -42,13 +42,6 @@ const ( GrantLeaderType = "grant-leader" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - grantLeaderCounter = schedulerCounter.WithLabelValues(GrantLeaderName, "schedule") - grantLeaderNoFollowerCounter = schedulerCounter.WithLabelValues(GrantLeaderName, "no-follower") - grantLeaderNewOperatorCounter = schedulerCounter.WithLabelValues(GrantLeaderName, "new-operator") -) - type grantLeaderSchedulerConfig struct { syncutil.RWMutex storage endpoint.ConfigStorage diff --git a/pkg/schedule/schedulers/hot_region.go b/pkg/schedule/schedulers/hot_region.go index d20473fb010..d7e83fd4fb2 100644 --- a/pkg/schedule/schedulers/hot_region.go +++ b/pkg/schedule/schedulers/hot_region.go @@ -71,44 +71,6 @@ var ( statisticsInterval = time.Second ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - hotSchedulerCounter = schedulerCounter.WithLabelValues(HotRegionName, "schedule") - hotSchedulerSkipCounter = schedulerCounter.WithLabelValues(HotRegionName, "skip") - hotSchedulerSearchRevertRegionsCounter = schedulerCounter.WithLabelValues(HotRegionName, "search_revert_regions") - hotSchedulerNotSameEngineCounter = schedulerCounter.WithLabelValues(HotRegionName, "not_same_engine") - hotSchedulerNoRegionCounter = schedulerCounter.WithLabelValues(HotRegionName, "no_region") - hotSchedulerUnhealthyReplicaCounter = schedulerCounter.WithLabelValues(HotRegionName, "unhealthy_replica") - hotSchedulerAbnormalReplicaCounter = schedulerCounter.WithLabelValues(HotRegionName, "abnormal_replica") - hotSchedulerCreateOperatorFailedCounter = schedulerCounter.WithLabelValues(HotRegionName, "create_operator_failed") - hotSchedulerNewOperatorCounter = schedulerCounter.WithLabelValues(HotRegionName, "new_operator") - hotSchedulerSnapshotSenderLimitCounter = schedulerCounter.WithLabelValues(HotRegionName, "snapshot_sender_limit") - - // counter related with the split region - hotSchedulerNotFoundSplitKeysCounter = schedulerCounter.WithLabelValues(HotRegionName, "not_found_split_keys") - hotSchedulerRegionBucketsNotHotCounter = schedulerCounter.WithLabelValues(HotRegionName, "region_buckets_not_hot") - hotSchedulerOnlyOneBucketsHotCounter = schedulerCounter.WithLabelValues(HotRegionName, "only_one_buckets_hot") - hotSchedulerHotBucketNotValidCounter = schedulerCounter.WithLabelValues(HotRegionName, "hot_buckets_not_valid") - hotSchedulerRegionBucketsSingleHotSpotCounter = schedulerCounter.WithLabelValues(HotRegionName, "region_buckets_single_hot_spot") - hotSchedulerSplitSuccessCounter = schedulerCounter.WithLabelValues(HotRegionName, "split_success") - hotSchedulerNeedSplitBeforeScheduleCounter = schedulerCounter.WithLabelValues(HotRegionName, "need_split_before_move_peer") - hotSchedulerRegionTooHotNeedSplitCounter = schedulerCounter.WithLabelValues(HotRegionName, "region_is_too_hot_need_split") - - hotSchedulerMoveLeaderCounter = schedulerCounter.WithLabelValues(HotRegionName, moveLeader.String()) - hotSchedulerMovePeerCounter = schedulerCounter.WithLabelValues(HotRegionName, movePeer.String()) - hotSchedulerTransferLeaderCounter = schedulerCounter.WithLabelValues(HotRegionName, transferLeader.String()) - - readSkipAllDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "read-skip-all-dim-uniform-store") - writeSkipAllDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "write-skip-all-dim-uniform-store") - readSkipByteDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "read-skip-byte-uniform-store") - writeSkipByteDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "write-skip-byte-uniform-store") - readSkipKeyDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "read-skip-key-uniform-store") - writeSkipKeyDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "write-skip-key-uniform-store") - readSkipQueryDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "read-skip-query-uniform-store") - writeSkipQueryDimUniformStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "write-skip-query-uniform-store") - pendingOpFailsStoreCounter = schedulerCounter.WithLabelValues(HotRegionName, "pending-op-fails") -) - type baseHotScheduler struct { *BaseScheduler // stLoadInfos contain store statistics information by resource type. diff --git a/pkg/schedule/schedulers/label.go b/pkg/schedule/schedulers/label.go index 24875e3e26a..6b7a98f8d02 100644 --- a/pkg/schedule/schedulers/label.go +++ b/pkg/schedule/schedulers/label.go @@ -34,15 +34,6 @@ const ( LabelType = "label" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - labelCounter = schedulerCounter.WithLabelValues(LabelName, "schedule") - labelNewOperatorCounter = schedulerCounter.WithLabelValues(LabelName, "new-operator") - labelNoTargetCounter = schedulerCounter.WithLabelValues(LabelName, "no-target") - labelSkipCounter = schedulerCounter.WithLabelValues(LabelName, "skip") - labelNoRegionCounter = schedulerCounter.WithLabelValues(LabelName, "no-region") -) - type labelSchedulerConfig struct { Name string `json:"name"` Ranges []core.KeyRange `json:"ranges"` diff --git a/pkg/schedule/schedulers/metrics.go b/pkg/schedule/schedulers/metrics.go index 34e4606a7ce..f8bd2b4d686 100644 --- a/pkg/schedule/schedulers/metrics.go +++ b/pkg/schedule/schedulers/metrics.go @@ -14,7 +14,10 @@ package schedulers -import "github.com/prometheus/client_golang/prometheus" +import ( + "github.com/prometheus/client_golang/prometheus" + types "github.com/tikv/pd/pkg/schedule/type" +) var ( schedulerStatusGauge = prometheus.NewGaugeVec( @@ -161,3 +164,180 @@ func init() { prometheus.MustRegister(storeSlowTrendMiscGauge) prometheus.MustRegister(HotPendingSum) } + +func balanceLeaderCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.BalanceLeaderScheduler.String(), event) +} + +func balanceRegionCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.BalanceRegionScheduler.String(), event) +} + +func evictLeaderCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.EvictLeaderScheduler.String(), event) +} + +func grantHotRegionCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.GrantHotRegionScheduler.String(), event) +} + +func grantLeaderCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.GrantHotRegionScheduler.String(), event) +} + +func hotRegionCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.HotRegionScheduler.String(), event) +} + +func labelCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.LabelScheduler.String(), event) +} + +func randomMergeCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.RandomMergeScheduler.String(), event) +} + +func scatterRangeCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.ScatterRangeScheduler.String(), event) +} + +func shuffleHotRegionCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.ShuffleHotRegionScheduler.String(), event) +} + +func shuffleLeaderCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.ShuffleLeaderScheduler.String(), event) +} + +func shuffleRegionCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.ShuffleRegionScheduler.String(), event) +} + +func splitBucketCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.SplitBucketScheduler.String(), event) +} + +func transferWitnessLeaderCounterWithEvent(event string) prometheus.Counter { + return schedulerCounter.WithLabelValues(types.TransferWitnessLeaderScheduler.String(), event) +} + +// WithLabelValues is a heavy operation, define variable to avoid call it every time. +var ( + balanceLeaderScheduleCounter = balanceLeaderCounterWithEvent("schedule") + balanceLeaderNoLeaderRegionCounter = balanceLeaderCounterWithEvent("no-leader-region") + balanceLeaderRegionHotCounter = balanceLeaderCounterWithEvent("region-hot") + balanceLeaderNoTargetStoreCounter = balanceLeaderCounterWithEvent("no-target-store") + balanceLeaderNoFollowerRegionCounter = balanceLeaderCounterWithEvent("no-follower-region") + balanceLeaderSkipCounter = balanceLeaderCounterWithEvent("skip") + balanceLeaderNewOpCounter = balanceLeaderCounterWithEvent("new-operator") + + balanceRegionScheduleCounter = balanceRegionCounterWithEvent("schedule") + balanceRegionNoRegionCounter = balanceRegionCounterWithEvent("no-region") + balanceRegionHotCounter = balanceRegionCounterWithEvent("region-hot") + balanceRegionNoLeaderCounter = balanceRegionCounterWithEvent("no-leader") + balanceRegionNewOpCounter = balanceRegionCounterWithEvent("new-operator") + balanceRegionSkipCounter = balanceRegionCounterWithEvent("skip") + balanceRegionCreateOpFailCounter = balanceRegionCounterWithEvent("create-operator-fail") + balanceRegionNoReplacementCounter = balanceRegionCounterWithEvent("no-replacement") + + evictLeaderCounter = evictLeaderCounterWithEvent("schedule") + evictLeaderNoLeaderCounter = evictLeaderCounterWithEvent("no-leader") + evictLeaderPickUnhealthyCounter = evictLeaderCounterWithEvent("pick-unhealthy-region") + evictLeaderNoTargetStoreCounter = evictLeaderCounterWithEvent("no-target-store") + evictLeaderNewOperatorCounter = evictLeaderCounterWithEvent("new-operator") + + evictSlowStoreCounter = schedulerCounter.WithLabelValues(types.EvictSlowStoreScheduler.String(), "schedule") + + grantHotRegionCounter = grantHotRegionCounterWithEvent("schedule") + grantHotRegionSkipCounter = grantHotRegionCounterWithEvent("skip") + + grantLeaderCounter = grantLeaderCounterWithEvent("schedule") + grantLeaderNoFollowerCounter = grantLeaderCounterWithEvent("no-follower") + grantLeaderNewOperatorCounter = grantLeaderCounterWithEvent("new-operator") + + // counter related with the hot region + hotSchedulerCounter = hotRegionCounterWithEvent("schedule") + hotSchedulerSkipCounter = hotRegionCounterWithEvent("skip") + hotSchedulerSearchRevertRegionsCounter = hotRegionCounterWithEvent("search_revert_regions") + hotSchedulerNotSameEngineCounter = hotRegionCounterWithEvent("not_same_engine") + hotSchedulerNoRegionCounter = hotRegionCounterWithEvent("no_region") + hotSchedulerUnhealthyReplicaCounter = hotRegionCounterWithEvent("unhealthy_replica") + hotSchedulerAbnormalReplicaCounter = hotRegionCounterWithEvent("abnormal_replica") + hotSchedulerCreateOperatorFailedCounter = hotRegionCounterWithEvent("create_operator_failed") + hotSchedulerNewOperatorCounter = hotRegionCounterWithEvent("new_operator") + hotSchedulerSnapshotSenderLimitCounter = hotRegionCounterWithEvent("snapshot_sender_limit") + // hot region counter related with the split region + hotSchedulerNotFoundSplitKeysCounter = hotRegionCounterWithEvent("not_found_split_keys") + hotSchedulerRegionBucketsNotHotCounter = hotRegionCounterWithEvent("region_buckets_not_hot") + hotSchedulerOnlyOneBucketsHotCounter = hotRegionCounterWithEvent("only_one_buckets_hot") + hotSchedulerHotBucketNotValidCounter = hotRegionCounterWithEvent("hot_buckets_not_valid") + hotSchedulerRegionBucketsSingleHotSpotCounter = hotRegionCounterWithEvent("region_buckets_single_hot_spot") + hotSchedulerSplitSuccessCounter = hotRegionCounterWithEvent("split_success") + hotSchedulerNeedSplitBeforeScheduleCounter = hotRegionCounterWithEvent("need_split_before_move_peer") + hotSchedulerRegionTooHotNeedSplitCounter = hotRegionCounterWithEvent("region_is_too_hot_need_split") + // hot region counter related with the move peer + hotSchedulerMoveLeaderCounter = hotRegionCounterWithEvent(moveLeader.String()) + hotSchedulerMovePeerCounter = hotRegionCounterWithEvent(movePeer.String()) + hotSchedulerTransferLeaderCounter = hotRegionCounterWithEvent(transferLeader.String()) + // hot region counter related with reading and writing + readSkipAllDimUniformStoreCounter = hotRegionCounterWithEvent("read-skip-all-dim-uniform-store") + writeSkipAllDimUniformStoreCounter = hotRegionCounterWithEvent("write-skip-all-dim-uniform-store") + readSkipByteDimUniformStoreCounter = hotRegionCounterWithEvent("read-skip-byte-uniform-store") + writeSkipByteDimUniformStoreCounter = hotRegionCounterWithEvent("write-skip-byte-uniform-store") + readSkipKeyDimUniformStoreCounter = hotRegionCounterWithEvent("read-skip-key-uniform-store") + writeSkipKeyDimUniformStoreCounter = hotRegionCounterWithEvent("write-skip-key-uniform-store") + readSkipQueryDimUniformStoreCounter = hotRegionCounterWithEvent("read-skip-query-uniform-store") + writeSkipQueryDimUniformStoreCounter = hotRegionCounterWithEvent("write-skip-query-uniform-store") + pendingOpFailsStoreCounter = hotRegionCounterWithEvent("pending-op-fails") + + labelCounter = labelCounterWithEvent("schedule") + labelNewOperatorCounter = labelCounterWithEvent("new-operator") + labelNoTargetCounter = labelCounterWithEvent("no-target") + labelSkipCounter = labelCounterWithEvent("skip") + labelNoRegionCounter = labelCounterWithEvent("no-region") + + randomMergeCounter = randomMergeCounterWithEvent("schedule") + randomMergeNewOperatorCounter = randomMergeCounterWithEvent("new-operator") + randomMergeNoSourceStoreCounter = randomMergeCounterWithEvent("no-source-store") + randomMergeNoRegionCounter = randomMergeCounterWithEvent("no-region") + randomMergeNoTargetStoreCounter = randomMergeCounterWithEvent("no-target-store") + randomMergeNotAllowedCounter = randomMergeCounterWithEvent("not-allowed") + + scatterRangeCounter = scatterRangeCounterWithEvent("schedule") + scatterRangeNewOperatorCounter = scatterRangeCounterWithEvent("new-operator") + scatterRangeNewLeaderOperatorCounter = scatterRangeCounterWithEvent("new-leader-operator") + scatterRangeNewRegionOperatorCounter = scatterRangeCounterWithEvent("new-region-operator") + scatterRangeNoNeedBalanceRegionCounter = scatterRangeCounterWithEvent("no-need-balance-region") + scatterRangeNoNeedBalanceLeaderCounter = scatterRangeCounterWithEvent("no-need-balance-leader") + + shuffleHotRegionCounter = shuffleHotRegionCounterWithEvent("schedule") + shuffleHotRegionNewOperatorCounter = shuffleHotRegionCounterWithEvent("new-operator") + shuffleHotRegionSkipCounter = shuffleHotRegionCounterWithEvent("skip") + + shuffleLeaderCounter = shuffleLeaderCounterWithEvent("schedule") + shuffleLeaderNewOperatorCounter = shuffleLeaderCounterWithEvent("new-operator") + shuffleLeaderNoTargetStoreCounter = shuffleLeaderCounterWithEvent("no-target-store") + shuffleLeaderNoFollowerCounter = shuffleLeaderCounterWithEvent("no-follower") + + shuffleRegionCounter = shuffleRegionCounterWithEvent("schedule") + shuffleRegionNewOperatorCounter = shuffleRegionCounterWithEvent("new-operator") + shuffleRegionNoRegionCounter = shuffleRegionCounterWithEvent("no-region") + shuffleRegionNoNewPeerCounter = shuffleRegionCounterWithEvent("no-new-peer") + shuffleRegionCreateOperatorFailCounter = shuffleRegionCounterWithEvent("create-operator-fail") + shuffleRegionNoSourceStoreCounter = shuffleRegionCounterWithEvent("no-source-store") + + splitBucketDisableCounter = splitBucketCounterWithEvent("bucket-disable") + splitBuckerSplitLimitCounter = splitBucketCounterWithEvent("split-limit") + splitBucketScheduleCounter = splitBucketCounterWithEvent("schedule") + splitBucketNoRegionCounter = splitBucketCounterWithEvent("no-region") + splitBucketRegionTooSmallCounter = splitBucketCounterWithEvent("region-too-small") + splitBucketOperatorExistCounter = splitBucketCounterWithEvent("operator-exist") + splitBucketKeyRangeNotMatchCounter = splitBucketCounterWithEvent("key-range-not-match") + splitBucketNoSplitKeysCounter = splitBucketCounterWithEvent("no-split-keys") + splitBucketCreateOperatorFailCounter = splitBucketCounterWithEvent("create-operator-fail") + splitBucketNewOperatorCounter = splitBucketCounterWithEvent("new-operator") + + transferWitnessLeaderCounter = transferWitnessLeaderCounterWithEvent("schedule") + transferWitnessLeaderNewOperatorCounter = transferWitnessLeaderCounterWithEvent("new-operator") + transferWitnessLeaderNoTargetStoreCounter = transferWitnessLeaderCounterWithEvent("no-target-store") +) diff --git a/pkg/schedule/schedulers/random_merge.go b/pkg/schedule/schedulers/random_merge.go index 7fec0bd9530..ff96afe03eb 100644 --- a/pkg/schedule/schedulers/random_merge.go +++ b/pkg/schedule/schedulers/random_merge.go @@ -35,16 +35,6 @@ const ( RandomMergeType = "random-merge" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - randomMergeCounter = schedulerCounter.WithLabelValues(RandomMergeName, "schedule") - randomMergeNewOperatorCounter = schedulerCounter.WithLabelValues(RandomMergeName, "new-operator") - randomMergeNoSourceStoreCounter = schedulerCounter.WithLabelValues(RandomMergeName, "no-source-store") - randomMergeNoRegionCounter = schedulerCounter.WithLabelValues(RandomMergeName, "no-region") - randomMergeNoTargetStoreCounter = schedulerCounter.WithLabelValues(RandomMergeName, "no-target-store") - randomMergeNotAllowedCounter = schedulerCounter.WithLabelValues(RandomMergeName, "not-allowed") -) - type randomMergeSchedulerConfig struct { Name string `json:"name"` Ranges []core.KeyRange `json:"ranges"` diff --git a/pkg/schedule/schedulers/scatter_range.go b/pkg/schedule/schedulers/scatter_range.go index ebee66dc207..17c67a154ab 100644 --- a/pkg/schedule/schedulers/scatter_range.go +++ b/pkg/schedule/schedulers/scatter_range.go @@ -38,16 +38,6 @@ const ( ScatterRangeName = "scatter-range" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - scatterRangeCounter = schedulerCounter.WithLabelValues(ScatterRangeName, "schedule") - scatterRangeNewOperatorCounter = schedulerCounter.WithLabelValues(ScatterRangeName, "new-operator") - scatterRangeNewLeaderOperatorCounter = schedulerCounter.WithLabelValues(ScatterRangeName, "new-leader-operator") - scatterRangeNewRegionOperatorCounter = schedulerCounter.WithLabelValues(ScatterRangeName, "new-region-operator") - scatterRangeNoNeedBalanceRegionCounter = schedulerCounter.WithLabelValues(ScatterRangeName, "no-need-balance-region") - scatterRangeNoNeedBalanceLeaderCounter = schedulerCounter.WithLabelValues(ScatterRangeName, "no-need-balance-leader") -) - type scatterRangeSchedulerConfig struct { syncutil.RWMutex storage endpoint.ConfigStorage diff --git a/pkg/schedule/schedulers/shuffle_hot_region.go b/pkg/schedule/schedulers/shuffle_hot_region.go index 4b5b5fd68bf..f4b566c56a4 100644 --- a/pkg/schedule/schedulers/shuffle_hot_region.go +++ b/pkg/schedule/schedulers/shuffle_hot_region.go @@ -41,13 +41,6 @@ const ( ShuffleHotRegionType = "shuffle-hot-region" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - shuffleHotRegionCounter = schedulerCounter.WithLabelValues(ShuffleHotRegionName, "schedule") - shuffleHotRegionNewOperatorCounter = schedulerCounter.WithLabelValues(ShuffleHotRegionName, "new-operator") - shuffleHotRegionSkipCounter = schedulerCounter.WithLabelValues(ShuffleHotRegionName, "skip") -) - type shuffleHotRegionSchedulerConfig struct { syncutil.RWMutex storage endpoint.ConfigStorage diff --git a/pkg/schedule/schedulers/shuffle_leader.go b/pkg/schedule/schedulers/shuffle_leader.go index 5b3dfd9fd20..17b5fae6448 100644 --- a/pkg/schedule/schedulers/shuffle_leader.go +++ b/pkg/schedule/schedulers/shuffle_leader.go @@ -32,14 +32,6 @@ const ( ShuffleLeaderType = "shuffle-leader" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - shuffleLeaderCounter = schedulerCounter.WithLabelValues(ShuffleLeaderName, "schedule") - shuffleLeaderNewOperatorCounter = schedulerCounter.WithLabelValues(ShuffleLeaderName, "new-operator") - shuffleLeaderNoTargetStoreCounter = schedulerCounter.WithLabelValues(ShuffleLeaderName, "no-target-store") - shuffleLeaderNoFollowerCounter = schedulerCounter.WithLabelValues(ShuffleLeaderName, "no-follower") -) - type shuffleLeaderSchedulerConfig struct { Name string `json:"name"` Ranges []core.KeyRange `json:"ranges"` diff --git a/pkg/schedule/schedulers/shuffle_region.go b/pkg/schedule/schedulers/shuffle_region.go index b1a100384ae..57f6c618962 100644 --- a/pkg/schedule/schedulers/shuffle_region.go +++ b/pkg/schedule/schedulers/shuffle_region.go @@ -33,16 +33,6 @@ const ( ShuffleRegionType = "shuffle-region" ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - shuffleRegionCounter = schedulerCounter.WithLabelValues(ShuffleRegionName, "schedule") - shuffleRegionNewOperatorCounter = schedulerCounter.WithLabelValues(ShuffleRegionName, "new-operator") - shuffleRegionNoRegionCounter = schedulerCounter.WithLabelValues(ShuffleRegionName, "no-region") - shuffleRegionNoNewPeerCounter = schedulerCounter.WithLabelValues(ShuffleRegionName, "no-new-peer") - shuffleRegionCreateOperatorFailCounter = schedulerCounter.WithLabelValues(ShuffleRegionName, "create-operator-fail") - shuffleRegionNoSourceStoreCounter = schedulerCounter.WithLabelValues(ShuffleRegionName, "no-source-store") -) - type shuffleRegionScheduler struct { *BaseScheduler conf *shuffleRegionSchedulerConfig diff --git a/pkg/schedule/schedulers/split_bucket.go b/pkg/schedule/schedulers/split_bucket.go index 9b049bf6ba1..4516dfe4433 100644 --- a/pkg/schedule/schedulers/split_bucket.go +++ b/pkg/schedule/schedulers/split_bucket.go @@ -45,20 +45,6 @@ const ( defaultSplitLimit = 10 ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - splitBucketDisableCounter = schedulerCounter.WithLabelValues(SplitBucketName, "bucket-disable") - splitBuckerSplitLimitCounter = schedulerCounter.WithLabelValues(SplitBucketName, "split-limit") - splitBucketScheduleCounter = schedulerCounter.WithLabelValues(SplitBucketName, "schedule") - splitBucketNoRegionCounter = schedulerCounter.WithLabelValues(SplitBucketName, "no-region") - splitBucketRegionTooSmallCounter = schedulerCounter.WithLabelValues(SplitBucketName, "region-too-small") - splitBucketOperatorExistCounter = schedulerCounter.WithLabelValues(SplitBucketName, "operator-exist") - splitBucketKeyRangeNotMatchCounter = schedulerCounter.WithLabelValues(SplitBucketName, "key-range-not-match") - splitBucketNoSplitKeysCounter = schedulerCounter.WithLabelValues(SplitBucketName, "no-split-keys") - splitBucketCreateOperatorFailCounter = schedulerCounter.WithLabelValues(SplitBucketName, "create-operator-fail") - splitBucketNewOperatorCounter = schedulerCounter.WithLabelValues(SplitBucketName, "new-operator") -) - func initSplitBucketConfig() *splitBucketSchedulerConfig { return &splitBucketSchedulerConfig{ Degree: defaultHotDegree, diff --git a/pkg/schedule/schedulers/transfer_witness_leader.go b/pkg/schedule/schedulers/transfer_witness_leader.go index 9ba78985d13..2050194b9ae 100644 --- a/pkg/schedule/schedulers/transfer_witness_leader.go +++ b/pkg/schedule/schedulers/transfer_witness_leader.go @@ -40,13 +40,6 @@ const ( transferWitnessLeaderRecvMaxRegionSize = 10000 ) -var ( - // WithLabelValues is a heavy operation, define variable to avoid call it every time. - transferWitnessLeaderCounter = schedulerCounter.WithLabelValues(TransferWitnessLeaderName, "schedule") - transferWitnessLeaderNewOperatorCounter = schedulerCounter.WithLabelValues(TransferWitnessLeaderName, "new-operator") - transferWitnessLeaderNoTargetStoreCounter = schedulerCounter.WithLabelValues(TransferWitnessLeaderName, "no-target-store") -) - type transferWitnessLeaderScheduler struct { *BaseScheduler regions chan *core.RegionInfo diff --git a/pkg/schedule/type/type.go b/pkg/schedule/type/type.go index d872bf0408c..65b2f0f682d 100644 --- a/pkg/schedule/type/type.go +++ b/pkg/schedule/type/type.go @@ -33,4 +33,40 @@ const ( RuleChecker CheckerSchedulerType = "rule-checker" // SplitChecker is the name for split checker. SplitChecker CheckerSchedulerType = "split-checker" + + // BalanceLeaderScheduler is balance leader scheduler name. + BalanceLeaderScheduler CheckerSchedulerType = "balance-leader-scheduler" + // BalanceRegionScheduler is balance region scheduler name. + BalanceRegionScheduler CheckerSchedulerType = "balance-region-scheduler" + // BalanceWitnessScheduler is balance witness scheduler name. + BalanceWitnessScheduler CheckerSchedulerType = "balance-witness-scheduler" + // EvictLeaderScheduler is evict leader scheduler name. + EvictLeaderScheduler CheckerSchedulerType = "evict-leader-scheduler" + // EvictSlowStoreScheduler is evict leader scheduler name. + EvictSlowStoreScheduler CheckerSchedulerType = "evict-slow-store-scheduler" + // EvictSlowTrendScheduler is evict leader by slow trend scheduler name. + EvictSlowTrendScheduler CheckerSchedulerType = "evict-slow-trend-scheduler" + // GrantLeaderScheduler is grant leader scheduler name. + GrantLeaderScheduler CheckerSchedulerType = "grant-leader-scheduler" + // GrantHotRegionScheduler is grant hot region scheduler name. + GrantHotRegionScheduler CheckerSchedulerType = "grant-hot-region-scheduler" + // HotRegionScheduler is balance hot region scheduler name. + HotRegionScheduler CheckerSchedulerType = "balance-hot-region-scheduler" + // RandomMergeScheduler is random merge scheduler name. + RandomMergeScheduler CheckerSchedulerType = "random-merge-scheduler" + // ScatterRangeScheduler is scatter range scheduler name. + // TODO: update to `scatter-range-scheduler` + ScatterRangeScheduler CheckerSchedulerType = "scatter-range" + // ShuffleHotRegionScheduler is shuffle hot region scheduler name. + ShuffleHotRegionScheduler CheckerSchedulerType = "shuffle-hot-region-scheduler" + // ShuffleLeaderScheduler is shuffle leader scheduler name. + ShuffleLeaderScheduler CheckerSchedulerType = "shuffle-leader-scheduler" + // ShuffleRegionScheduler is shuffle region scheduler name. + ShuffleRegionScheduler CheckerSchedulerType = "shuffle-region-scheduler" + // SplitBucketScheduler is the split bucket name. + SplitBucketScheduler CheckerSchedulerType = "split-bucket-scheduler" + // TransferWitnessLeaderScheduler is transfer witness leader scheduler name. + TransferWitnessLeaderScheduler CheckerSchedulerType = "transfer-witness-leader-scheduler" + // LabelScheduler is label scheduler name. + LabelScheduler CheckerSchedulerType = "label-scheduler" )