Skip to content

Commit

Permalink
metrics: add index speed metric (#12374) (#12390)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Oct 21, 2019
1 parent e1d9f7e commit dbd61c9
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 @@ -894,6 +894,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 @@ -919,6 +921,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 @@ -70,6 +70,7 @@ func RegisterMetrics() {
prometheus.MustRegister(PreparedStmtGauge)
prometheus.MustRegister(CriticalErrorCounter)
prometheus.MustRegister(DDLCounter)
prometheus.MustRegister(AddIndexTotalCounter)
prometheus.MustRegister(DDLWorkerHistogram)
prometheus.MustRegister(DeploySyncerHistogram)
prometheus.MustRegister(DistSQLPartialCountHistogram)
Expand Down

0 comments on commit dbd61c9

Please sign in to comment.