Skip to content

Commit

Permalink
metrics:fix add index duration bucket dosen't work (pingcap#6478)
Browse files Browse the repository at this point in the history
* fix add index duration bucket dosen't work
  • Loading branch information
ciscoxll authored May 28, 2018
1 parent eaf8296 commit 4607251
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,15 @@ func (d *ddl) backfillBatchTasks(startTime time.Time, startHandle int64, reorgIn
err1 := kv.RunInNewTxn(d.store, true, func(txn kv.Transaction) error {
return errors.Trace(reorgInfo.UpdateHandle(txn, nextHandle))
})
metrics.BatchAddIdxHistogram.WithLabelValues(metrics.LblError).Observe(elapsedTime)
log.Warnf("[ddl-reorg] total added index for %d rows, this task [%d,%d) add index for %d failed %v, take time %v, update handle err %v",
*totalAddedCount, startHandle, nextHandle, taskAddedCount, err, elapsedTime, err1)
return errors.Trace(err)
}

// nextHandle will be updated periodically in runReorgJob, so no need to update it here.
d.reorgCtx.setNextHandle(nextHandle)
metrics.BatchAddIdxHistogram.Observe(elapsedTime)
metrics.BatchAddIdxHistogram.WithLabelValues(metrics.LblOK).Observe(elapsedTime)
log.Infof("[ddl-reorg] total added index for %d rows, this task [%d,%d) added index for %d rows, take time %v",
*totalAddedCount, startHandle, nextHandle, taskAddedCount, elapsedTime)
return nil
Expand Down
4 changes: 2 additions & 2 deletions metrics/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ var (
Buckets: prometheus.ExponentialBuckets(0.01, 2, 20),
}, []string{LblType, LblResult})

BatchAddIdxHistogram = prometheus.NewHistogram(
BatchAddIdxHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "tidb",
Subsystem: "ddl",
Name: "batch_add_idx_duration_seconds",
Help: "Bucketed histogram of processing time (s) of batch handle data",
Buckets: prometheus.ExponentialBuckets(0.001, 2, 20),
})
}, []string{LblType})

SyncerInit = "init"
SyncerRestart = "restart"
Expand Down

0 comments on commit 4607251

Please sign in to comment.