Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log-backup: adapt the new metrics (#36479) #36510

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions br/pkg/stream/stream_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (p *printByJSON) PrintTasks() {
p.console.Println(mustMarshal(tasks))
}

var logCountSumRe = regexp.MustCompile(`tikv_stream_handle_kv_batch_sum ([0-9]+)`)
var logCountSumRe = regexp.MustCompile(`tikv_(?:stream|log_backup)_handle_kv_batch_sum ([0-9]+)`)

type PDInfoProvider interface {
GetPDClient() pd.Client
Expand Down Expand Up @@ -279,10 +279,10 @@ func MaybeQPS(ctx context.Context, mgr PDInfoProvider) (float64, error) {
return 0, err
}
matches := logCountSumRe.FindSubmatch(data)
log.Info("get qps", zap.ByteStrings("matches", matches), logutil.Redact(zap.String("addr", statusAddr)))
if len(matches) < 2 {
return 42, nil
}
log.Info("get qps", zap.ByteStrings("matches", matches), logutil.Redact(zap.String("addr", statusAddr)))
return strconv.ParseUint(string(matches[1]), 10, 64)
}
qpsMap := new(sync.Map)
Expand All @@ -303,7 +303,7 @@ func MaybeQPS(ctx context.Context, mgr PDInfoProvider) (float64, error) {
return errors.Annotatef(err, "failed to get count from %s", statusAddr)
}
elapsed := float64(time.Since(start)) / float64(time.Second)
log.Info("calc qps", zap.Uint64("diff", c1-c0), zap.Float64("elapsed", elapsed))
log.Info("calc qps", zap.Uint64("diff", c1-c0), zap.Float64("elapsed", elapsed), zap.Uint64("c0", c0), zap.Uint64("c1", c1))

qpsMap.Store(s.GetId(), float64(c1-c0)/elapsed)
return nil
Expand Down