-
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: attach const label keyspace_id #41693
metrics: attach const label keyspace_id #41693
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Skipping CI for Draft Pull Request. |
server/metrics.go
Outdated
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package server |
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.
Some package, like server, executor, and so on, is too large to build in a short time. I suggest you can create a new package like executor/metrics
to put this file.
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.
done
The results of the manual test should be provided in this PR description. |
done |
The screenshot needs to be verified.When keyspace-name is configured, metrics will have the label of keyspace_id, if the keyspace-name is not configured, metrics will not have the label of keyspace_id, |
util/topsql/reporter/metrics.go
Outdated
ignoreExceedSQLCounter = metrics.TopSQLIgnoredCounter.WithLabelValues("ignore_exceed_sql") | ||
ignoreExceedPlanCounter = metrics.TopSQLIgnoredCounter.WithLabelValues("ignore_exceed_plan") | ||
ignoreCollectChannelFullCounter = metrics.TopSQLIgnoredCounter.WithLabelValues("ignore_collect_channel_full") | ||
ignoreExceedSQLCounter prometheus.Counter |
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 looks like most of the changes are such separation of declaration and initialization.
Do we have a strong motivation to deliver this change of code style?
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.
We will re-initialize metrics after getting keyspace
from config, and these corresponding metrics variables should also be re-initialized. Thus, we conduct the separation of declaration and initialization.
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 we just initialize metircs once?
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'm not sure, it's worth a try. But no matter whether the metrics are initialized once or twice, the separation of declaration and initialization is needed.
/test unit-test |
/retest-required |
metrics/wrapper.go
Outdated
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
var keyspaceLabels prometheus.Labels |
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.
We can use a more generic name so that we may add more labels in the future.
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.
sure
util/topsql/reporter/metrics.go
Outdated
ignoreExceedSQLCounter = metrics.TopSQLIgnoredCounter.WithLabelValues("ignore_exceed_sql") | ||
ignoreExceedPlanCounter = metrics.TopSQLIgnoredCounter.WithLabelValues("ignore_exceed_plan") | ||
ignoreCollectChannelFullCounter = metrics.TopSQLIgnoredCounter.WithLabelValues("ignore_collect_channel_full") | ||
ignoreExceedSQLCounter prometheus.Counter |
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 we just initialize metircs once?
4bf9c55
to
a5c3930
Compare
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
@ystaticy: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: a7b8b73
|
What problem does this PR solve?
Issue Number: close #41698
Problem Summary:
What is changed and how it works?
If
keyspace-name
is set in the configuration, the TiDB node will get the corresponding keyspace id from PD, and then register metrics with const label 'keyspace_id' attached.Check List
Tests
Manual test
keyspace-name
set in tidb config:keyspace-name
set in tidb config:pre-alloc
keyspace in config).Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.