Skip to content

Commit

Permalink
use metrics to record statistics
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Nov 3, 2022
1 parent 72e558e commit 981a481
Show file tree
Hide file tree
Showing 6 changed files with 45 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 @@ -196,7 +196,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 @@ -161,11 +161,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
27 changes: 27 additions & 0 deletions tools/pd-simulator/simulator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,35 @@ 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"})

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

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

func init() {
prometheus.MustRegister(snapDuration)
prometheus.MustRegister(schedulingCounter)
prometheus.MustRegister(snapRecvCounter)
prometheus.MustRegister(snapSendCounter)
}
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.

Loading

0 comments on commit 981a481

Please sign in to comment.