Skip to content

Commit

Permalink
stats: add metircs for high error rate feedback (#9209)
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Feb 12, 2019
1 parent 347c852 commit 8431d11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func RegisterMetrics() {
prometheus.MustRegister(GetTokenDurationHistogram)
prometheus.MustRegister(HandShakeErrorCounter)
prometheus.MustRegister(HandleJobHistogram)
prometheus.MustRegister(SignificantFeedbackCounter)
prometheus.MustRegister(JobsGauge)
prometheus.MustRegister(KeepAliveCounter)
prometheus.MustRegister(LoadPrivilegeCounter)
Expand Down
8 changes: 8 additions & 0 deletions metrics/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ var (
Name: "store_query_feedback_total",
Help: "Counter of storing query feedback.",
}, []string{LblType})

SignificantFeedbackCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "statistics",
Name: "high_error_rate_feedback_total",
Help: "Counter of query feedback whose actual count is much different than calculated by current statistics",
})
)
7 changes: 5 additions & 2 deletions statistics/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ func (s *SessionStatsCollector) StoreQueryFeedback(feedback interface{}, h *Hand
} else {
rate = math.Abs(expected-float64(q.actual)) / float64(q.actual)
}
if rate >= MinLogErrorRate && (q.actual >= MinLogScanCount || q.expected >= MinLogScanCount) && log.GetLevel() == log.DebugLevel {
q.logDetailedInfo(h)
if rate >= MinLogErrorRate && (q.actual >= MinLogScanCount || q.expected >= MinLogScanCount) {
metrics.SignificantFeedbackCounter.Inc()
if log.GetLevel() == log.DebugLevel {
q.logDetailedInfo(h)
}
}
metrics.StatsInaccuracyRate.Observe(rate)
s.Lock()
Expand Down

0 comments on commit 8431d11

Please sign in to comment.