Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
*: add apply worker metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
lonng committed Dec 27, 2018
1 parent 1880258 commit eb011cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lightning/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ var (
Buckets: prometheus.ExponentialBuckets(0.001, 3.1622776601683795, 10),
},
)
ApplyWorkerSecondsHistogram = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: "lightning",
Name: "apply_worker_seconds",
Help: "time needed to apply a worker",
Buckets: prometheus.ExponentialBuckets(0.001, 3.1622776601683795, 10),
}, []string{"name"},
)
BlockEncodeSecondsHistogram = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: "lightning",
Expand Down Expand Up @@ -167,6 +175,7 @@ func init() {
prometheus.MustRegister(ChecksumSecondsHistogram)
prometheus.MustRegister(ChunkParserReadRowSecondsHistogram)
prometheus.MustRegister(ChunkParserReadBlockSecondsHistogram)
prometheus.MustRegister(ApplyWorkerSecondsHistogram)
}

func RecordTableCount(status string, err error) {
Expand Down
3 changes: 3 additions & 0 deletions lightning/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package worker

import (
"context"
"time"

"github.com/pingcap/tidb-lightning/lightning/metric"
)
Expand Down Expand Up @@ -31,8 +32,10 @@ func NewRestoreWorkerPool(ctx context.Context, limit int, name string) *RestoreW
}

func (pool *RestoreWorkerPool) Apply() *RestoreWorker {
start := time.Now()
worker := <-pool.workers
metric.IdleWorkersGauge.WithLabelValues(pool.name).Set(float64(len(pool.workers)))
metric.ApplyWorkerSecondsHistogram.WithLabelValues(pool.name).Observe(time.Since(start).Seconds())
return worker
}
func (pool *RestoreWorkerPool) Recycle(worker *RestoreWorker) {
Expand Down

0 comments on commit eb011cd

Please sign in to comment.