Skip to content

Commit

Permalink
executor: add back metrics for select_result.go:fetchResp() (pingcap#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ichn-hu authored and sre-bot committed Dec 10, 2019
1 parent 206cdbe commit 72cd3f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion distsql/select_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ type selectResult struct {
copPlanIDs []fmt.Stringer
rootPlanID fmt.Stringer

memTracker *memory.Tracker
fetchDuration time.Duration
durationReported bool
memTracker *memory.Tracker
}

func (r *selectResult) Fetch(ctx context.Context) {
Expand All @@ -83,7 +85,10 @@ func (r *selectResult) Fetch(ctx context.Context) {
func (r *selectResult) fetchResp(ctx context.Context) error {
for {
r.respChkIdx = 0
startTime := time.Now()
resultSubset, err := r.resp.Next(ctx)
duration := time.Since(startTime)
r.fetchDuration += duration
if err != nil {
return errors.Trace(err)
}
Expand All @@ -92,6 +97,13 @@ func (r *selectResult) fetchResp(ctx context.Context) error {
}
if resultSubset == nil {
r.selectResp = nil
if !r.durationReported {
// final round of fetch
// TODO: Add a label to distinguish between success or failure.
// https://github.com/pingcap/tidb/issues/11397
metrics.DistSQLQueryHistgram.WithLabelValues(r.label, r.sqlType).Observe(r.fetchDuration.Seconds())
r.durationReported = true
}
return nil
}
r.selectResp = new(tipb.SelectResponse)
Expand Down

0 comments on commit 72cd3f2

Please sign in to comment.