-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 db QPS metric #9151
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9151 +/- ##
==========================================
- Coverage 67.2% 67.14% -0.06%
==========================================
Files 371 371
Lines 77353 77427 +74
==========================================
+ Hits 51985 51991 +6
- Misses 20720 20791 +71
+ Partials 4648 4645 -3
Continue to review full report at Codecov.
|
Great job! |
config/config.go
Outdated
@@ -61,7 +61,8 @@ type Config struct { | |||
TxnLocalLatches TxnLocalLatches `toml:"txn-local-latches" json:"txn-local-latches"` | |||
// Set sys variable lower-case-table-names, ref: https://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html. | |||
// TODO: We actually only support mode 2, which keeps the original case, but the comparison is case-insensitive. | |||
LowerCaseTableNames int `toml:"lower-case-table-names" json:"lower-case-table-names"` | |||
LowerCaseTableNames int `toml:"lower-case-table-names" json:"lower-case-table-names"` | |||
DbQPSMetricSwitch int64 `toml:"db-qps-metric-switch" json:"db-qps-metric-switch"` |
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.
- Why not define it as a bool?
- It is better to move it to
Line 143 in 41838ce
type Status struct { - How about rename it to
RecordQPSbyDB
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.
ok
@qazbnm456 |
executor/compiler.go
Outdated
@@ -125,6 +126,120 @@ func CountStmtNode(stmtNode ast.StmtNode, inRestrictedSQL bool) { | |||
metrics.StmtNodeCounter.WithLabelValues(GetStmtLabel(stmtNode)).Inc() | |||
} | |||
|
|||
// DbCountStmtNode records the number of statements with the same type and db. | |||
func DbCountStmtNode(stmtNode ast.StmtNode, inRestrictedSQL bool) { |
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 it is better to refactor CountStmtNode
instead of writing a new function.
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.
ok
go.mod
Outdated
@@ -84,7 +84,6 @@ require ( | |||
google.golang.org/genproto v0.0.0-20190108161440-ae2f86662275 // indirect | |||
google.golang.org/grpc v1.17.0 | |||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 | |||
gopkg.in/stretchr/testify.v1 v1.2.2 // indirect |
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 it is not a related change.
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.
This is go project auto update.
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.
rest LGTM
PTAL @lysu
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.
rest LGTM
config/config.toml.example
Outdated
@@ -119,6 +119,9 @@ metrics-addr = "" | |||
# Prometheus client push interval in second, set \"0\" to disable prometheus push. | |||
metrics-interval = 15 | |||
|
|||
# if enable tidb record db qps | |||
record-db-qps = true |
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 better to set it to false as default. Because it may make the server starting failure.
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.
OK
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.
ok
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 |
Thanks for your contribution, @iamzhoug37 ! |
What is changed and how it works?
metric result like this:
Check List
Tests
Code changes
Side effects
Related changes
tidb-ansible
repository