Skip to content

Commit

Permalink
add unstarted op metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Luffbee committed Aug 21, 2019
1 parent ba3d8ca commit 63a91f9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/schedulers/hot_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func isFinish(op *operator.Operator) bool {
return op.IsFinish() || op.IsTimeout()
}

func isStarted(op *operator.Operator) bool {
return op.GetStartTime().IsZero()
}

type balanceHotRegionsScheduler struct {
*baseScheduler
sync.RWMutex
Expand Down Expand Up @@ -198,13 +202,21 @@ func (h *balanceHotRegionsScheduler) Schedule(cluster schedule.Cluster) []*opera

func (h *balanceHotRegionsScheduler) updatePendingInfluence() {
h.influence.multWeight(0.1)
var unstarted_cnt uint = 0
var unstarted_sum time.Duration = 0
for op, infl := range h.pendingOps {
if isFinish(op) {
delete(h.pendingOps, op)
continue
}
if !isStarted(op) {
unstarted_cnt++
unstarted_sum += op.ElapsedTime()
}
h.influence.Add(&infl, 0.7)
}
pendingInfluenceGauge.WithLabelValues("unstarted_cnt", "--").Set(float64(unstarted_cnt))
pendingInfluenceGauge.WithLabelValues("unstarted_sum", "--").Set(float64(unstarted_sum) / float64(time.Millisecond))
for store, value := range h.influence.bytesRead {
pendingInfluenceGauge.WithLabelValues("bytes_read", fmt.Sprintf("store-%d", store)).Set(value)
}
Expand Down

0 comments on commit 63a91f9

Please sign in to comment.