Skip to content

Commit

Permalink
tools: use metrics to record statistics (#5673)
Browse files Browse the repository at this point in the history
ref #5468

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
  • Loading branch information
rleungx and ti-chi-bot committed Nov 25, 2022
1 parent 441f0fb commit 7593af1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 243 deletions.
1 change: 0 additions & 1 deletion tools/pd-simulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ EXIT:
}

fmt.Printf("%s [%s] total iteration: %d, time cost: %v\n", simResult, simCase, driver.TickCount(), time.Since(start))
driver.PrintStatistics()
if analysis.GetTransferCounter().IsValid {
analysis.GetTransferCounter().PrintResult()
}
Expand Down
5 changes: 0 additions & 5 deletions tools/pd-simulator/simulator/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ func (d *Driver) Check() bool {
return d.simCase.Checker(d.raftEngine.regionsInfo, stats)
}

// PrintStatistics prints the statistics of the scheduler.
func (d *Driver) PrintStatistics() {
d.raftEngine.schedulerStats.PrintStatistics()
}

// Start starts all nodes.
func (d *Driver) Start() error {
for _, n := range d.conn.Nodes {
Expand Down
18 changes: 18 additions & 0 deletions tools/pd-simulator/simulator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,26 @@ var (
Help: "Bucketed histogram of processing time (s) of handled snap requests.",
Buckets: prometheus.ExponentialBuckets(0.0005, 2, 20),
}, []string{"store", "type"})

schedulingCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "pd",
Subsystem: "schedule",
Name: "scheduling_count",
Help: "Counter of region scheduling",
}, []string{"type"})

snapshotCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "pd",
Subsystem: "schedule",
Name: "snapshot_count",
Help: "Counter of region snapshot",
}, []string{"store", "type"})
)

func init() {
prometheus.MustRegister(snapDuration)
prometheus.MustRegister(schedulingCounter)
prometheus.MustRegister(snapshotCounter)
}
2 changes: 0 additions & 2 deletions tools/pd-simulator/simulator/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type RaftEngine struct {
regionsInfo *core.RegionsInfo
conn *Connection
regionChange map[uint64][]uint64
schedulerStats *schedulerStatistics
regionSplitSize int64
regionSplitKeys int64
storeConfig *SimConfig
Expand All @@ -45,7 +44,6 @@ func NewRaftEngine(conf *cases.Case, conn *Connection, storeConfig *SimConfig) *
regionsInfo: core.NewRegionsInfo(),
conn: conn,
regionChange: make(map[uint64][]uint64),
schedulerStats: newSchedulerStatistics(),
regionSplitSize: conf.RegionSplitSize,
regionSplitKeys: conf.RegionSplitKeys,
storeConfig: storeConfig,
Expand Down
219 changes: 0 additions & 219 deletions tools/pd-simulator/simulator/statistics.go

This file was deleted.

0 comments on commit 7593af1

Please sign in to comment.