Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics: remove Keep Alive OPM metric #40142

Merged
merged 2 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ func RegisterMetrics() {
prometheus.MustRegister(SyncLoadHistogram)
prometheus.MustRegister(ReadStatsHistogram)
prometheus.MustRegister(JobsGauge)
prometheus.MustRegister(KeepAliveCounter)
prometheus.MustRegister(LoadPrivilegeCounter)
prometheus.MustRegister(InfoCacheCounters)
prometheus.MustRegister(LoadSchemaCounter)
Expand Down
8 changes: 0 additions & 8 deletions metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ var (
Help: "Counter of system time jumps backward.",
})

KeepAliveCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "monitor",
Name: "keep_alive_total",
Help: "Counter of TiDB keep alive.",
})

PlanCacheCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Expand Down
11 changes: 1 addition & 10 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,16 +788,7 @@ func setupMetrics() {
systimeErrHandler := func() {
metrics.TimeJumpBackCounter.Inc()
}
callBackCount := 0
successCallBack := func() {
callBackCount++
// It is callback by monitor per second, we increase metrics.KeepAliveCounter per 5s.
if callBackCount >= 5 {
callBackCount = 0
metrics.KeepAliveCounter.Inc()
}
}
go systimemon.StartMonitor(time.Now, systimeErrHandler, successCallBack)
go systimemon.StartMonitor(time.Now, systimeErrHandler)

pushMetric(cfg.Status.MetricsAddr, time.Duration(cfg.Status.MetricsInterval)*time.Second)
}
Expand Down
9 changes: 1 addition & 8 deletions util/systimemon/systime_mon.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,16 @@ import (
)

// StartMonitor calls systimeErrHandler if system time jump backward.
func StartMonitor(now func() time.Time, systimeErrHandler func(), successCallback func()) {
func StartMonitor(now func() time.Time, systimeErrHandler func()) {
logutil.BgLogger().Info("start system time monitor")
tick := time.NewTicker(100 * time.Millisecond)
defer tick.Stop()
tickCount := 0
for {
last := now().UnixNano()
<-tick.C
if now().UnixNano() < last {
logutil.BgLogger().Error("system time jump backward", zap.Int64("last", last))
systimeErrHandler()
}
// call successCallback per second.
tickCount++
if tickCount >= 10 {
tickCount = 0
successCallback()
}
}
}
2 changes: 1 addition & 1 deletion util/systimemon/systime_mon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestSystimeMonitor(t *testing.T) {
return time.Now().Add(-2 * time.Second)
}, func() {
errTriggered.Store(true)
}, func() {})
})

require.Eventually(t, errTriggered.Load, time.Second, 10*time.Millisecond)
}