Skip to content

Commit

Permalink
Fix the bug where the table name of SQL is missed (KindlingProject#284)
Browse files Browse the repository at this point in the history
* The end of the table name could be empty

Signed-off-by: Daxin Wang <[email protected]>

* update changelog

Signed-off-by: Daxin Wang <[email protected]>

* update the metrics doc

Signed-off-by: Daxin Wang <[email protected]>

* move the log to 'bug fixes'

Signed-off-by: Daxin Wang <[email protected]>
  • Loading branch information
dxsup authored Jul 1, 2022
1 parent 73b8fcc commit 13ae243
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
## Unreleased
### Enhancements
- Declare the 9500 port in the agent's deployment file ([#282](https://github.com/CloudDectective-Harmonycloud/kindling/pull/282))
### Bug fixes
- Fix the bug where the table name of SQL is missed if there is no trailing character at the end of the table name. ([#284](https://github.com/CloudDectective-Harmonycloud/kindling/pull/284))

## v0.3.0 - 2022-06-29
### New features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (merger SqlMerger) ParseStatement(statement string) string {

func newSqlParser(sqlType string, sqlKey string) SqlParser {
patternType := `(?i)(^\s*)` + sqlType + `(.*)`
patternKey := `(?i)(?m)` + "(" + sqlKey + ")" + `(\s+(\S*)\s|\n)`
patternKey := `(?i)(?m)` + "(" + sqlKey + ")" + `(\s+(\S*)\s*|\n)`

return SqlParser{
regexType: regexp.MustCompile(patternType),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func TestSqlMerger_InsertSql(t *testing.T) {
operator: "select",
datas: map[string][]string{
"select table *": {
"select * from table",
"select * from table ",
"select * from table where id = 1",
},
"select person *": {
Expand Down
2 changes: 1 addition & 1 deletion docs/prometheus_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Service metrics are generated from the server-side events, which are used to sho

| **Label** | **Example** | **Notes** |
| --- | --- | --- |
| `request_content` | select employee | SQL of MySQL. SQL has been truncated to avoid high-cardinality. The format is ['operation' 'space' 'table']. |
| `request_content` | select employee | SQL of MySQL. SQL has been truncated to avoid high-cardinality. The format is ['operation' 'space' 'table' '*']. |
| `response_content` | 1064 | Error code of MySQL. Only applicable when the response is in error type. See [codes introduction](https://dev.mysql.com/doc/mysql-errors/5.7/en/error-reference-introduction.html).|

- When protocol is `kafka`:
Expand Down

0 comments on commit 13ae243

Please sign in to comment.