Skip to content

Commit

Permalink
debug for limit
Browse files Browse the repository at this point in the history
Signed-off-by: lhy1024 <[email protected]>
  • Loading branch information
lhy1024 committed Aug 28, 2024
1 parent 09e272f commit 1093fc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/schedule/checker/checker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ func (c *Controller) CheckRegion(region *core.RegionInfo) []*operator.Operator {
}

if c.mergeChecker != nil {
operator.DebugIncOperatorCounter("op", opController.OperatorCount(operator.OpMerge))
operator.DebugIncOperatorCounter("limit", c.conf.GetMergeScheduleLimit())
allowed := opController.OperatorCount(operator.OpMerge) < c.conf.GetMergeScheduleLimit()
if !allowed {
operator.IncOperatorLimitCounter(c.mergeChecker.GetType(), operator.OpMerge)
Expand Down
13 changes: 13 additions & 0 deletions pkg/schedule/operator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ var (
Help: "Bucketed histogram of the operator region size.",
Buckets: prometheus.ExponentialBuckets(1, 2, 20), // 1MB~1TB
}, []string{"type"})
debugOperatorCounter = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "pd",
Subsystem: "schedule",
Name: "debug_operator_count",
Help: "Counter of debug schedule operators.",
}, []string{"type"})
)

func init() {
Expand All @@ -90,9 +97,15 @@ func init() {
prometheus.MustRegister(operatorDuration)
prometheus.MustRegister(operatorSizeHist)
prometheus.MustRegister(storeLimitCostCounter)
prometheus.MustRegister(debugOperatorCounter)
}

// IncOperatorLimitCounter increases the counter of operator meeting limit.
func IncOperatorLimitCounter(typ types.CheckerSchedulerType, kind OpKind) {
operatorLimitCounter.WithLabelValues(typ.String(), kind.String()).Inc()
}

// DebugIncOperatorCounter increases the counter of debug schedule operators.
func DebugIncOperatorCounter(typ string, num uint64) {
debugOperatorCounter.WithLabelValues(typ).Set(float64(num))
}

0 comments on commit 1093fc7

Please sign in to comment.