Skip to content

Commit

Permalink
metrics: add index speed metric (#12374) (#12389)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Oct 21, 2019
1 parent 2098cfe commit e584f43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ func (w *addIndexWorker) backfillIndexInTxn(handleRange reorgIndexTask) (taskCtx
return
}

var addIndexSpeedCounter = metrics.AddIndexTotalCounter.WithLabelValues("speed")

// handleBackfillTask backfills range [task.startHandle, task.endHandle) handle's index to table.
func (w *addIndexWorker) handleBackfillTask(d *ddlCtx, task *reorgIndexTask) *addIndexResult {
handleRange := *task
Expand All @@ -825,6 +827,7 @@ func (w *addIndexWorker) handleBackfillTask(d *ddlCtx, task *reorgIndexTask) *ad
return result
}

addIndexSpeedCounter.Add(float64(taskCtx.addedCount))
mergeAddIndexCtxToResult(&taskCtx, result)
w.ddlWorker.reorgCtx.increaseRowCount(int64(taskCtx.addedCount))

Expand Down
8 changes: 8 additions & 0 deletions metrics/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ var (
Name: "worker_operation_total",
Help: "Counter of creating ddl/worker and isowner.",
}, []string{LblType})

AddIndexTotalCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "ddl",
Name: "add_index_total",
Help: "Speed of add index",
}, []string{LblType})
)

// Label constants.
Expand Down
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func RegisterMetrics() {
prometheus.MustRegister(ConnGauge)
prometheus.MustRegister(CriticalErrorCounter)
prometheus.MustRegister(DDLCounter)
prometheus.MustRegister(AddIndexTotalCounter)
prometheus.MustRegister(DDLWorkerHistogram)
prometheus.MustRegister(DeploySyncerHistogram)
prometheus.MustRegister(DistSQLPartialCountHistogram)
Expand Down

0 comments on commit e584f43

Please sign in to comment.