-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: add metrics for bind info #10921
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10921 +/- ##
==========================================
Coverage ? 81.257%
==========================================
Files ? 423
Lines ? 90082
Branches ? 0
==========================================
Hits ? 73198
Misses ? 11583
Partials ? 5301 |
bindinfo/handle.go
Outdated
if meta.Status == Using { | ||
newCache[hash] = append(newCache[hash], meta) | ||
metrics.BindMemoryUsage.WithLabelValues(metrics.ScopeGlobal).Add(meta.size()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add a comment to explain why we don't decrease the memory size for the old data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is decreased in removeStaleBindMetas
, this line directly manipulates the cache, so it is handled here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also increase BindTotalGauge
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think no, or if we have multiply tidb, each of them will increase one for the same bindings, it will look like there are many bindings.
bindinfo/handle.go
Outdated
for i := len(metas) - 1; i >= 0; i-- { | ||
if metas[i].isStale(meta) { | ||
metrics.BindMemoryUsage.WithLabelValues(scope).Sub(metas[i].size()) | ||
if metas[i].Status == Using { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we decrease the counter no matter whether it is Using
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, currently it only means valid binds, and for global handles, it could only be using
.
metrics/bindinfo.go
Outdated
Subsystem: "bindinfo", | ||
Name: "bind_total_gauge", | ||
Help: "Total number of sql bind", | ||
}, []string{LblType}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this value be retrieved directly from system tables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can, but the system table only contains global level bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PTAL @zz-jason |
bindinfo/handle.go
Outdated
if meta.Status == Using { | ||
newCache[hash] = append(newCache[hash], meta) | ||
metrics.BindMemoryUsage.WithLabelValues(metrics.ScopeGlobal).Add(meta.size()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also increase BindTotalGauge
?
bindinfo/handle.go
Outdated
@@ -255,6 +257,7 @@ func (h *BindHandle) DropInvalidBindRecord() { | |||
if time.Since(invalidBindRecord.droppedTime) > 6*time.Second { | |||
delete(invalidBindRecordMap, key) | |||
} | |||
invalidBindRecord.bindRecord.updateMetrics(metrics.ScopeGlobal, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we only update the metrics when the delete
operation is performed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
cherry pick to release-3.0 in PR #11467 |
What problem does this PR solve?
Add metrics for bind info.
What is changed and how it works?
It adds metrics for
Check List
Tests
Code changes
Side effects
Related changes