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

stats: add metircs for high error rate feedback #9209

Merged
merged 6 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
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: 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(HighErrorRateFeedBackCounter)
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})

HighErrorRateFeedBackCounter = prometheus.NewCounter(
winoros marked this conversation as resolved.
Show resolved Hide resolved
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "statistics",
Name: "high_error_rate_feedback_total",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update ansible as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

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.HighErrorRateFeedBackCounter.Inc()
if log.GetLevel() == log.DebugLevel {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this log level to INFO or WARN?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part logs many things and has some heavy calculation. So it would be better to set it to debug level.

q.logDetailedInfo(h)
}
}
metrics.StatsInaccuracyRate.Observe(rate)
s.Lock()
Expand Down