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

[receiver/mysql] Add mysql.joins metric #14728

Closed
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions .chloggen/drosiek-mysql-select-metric.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: mysqlreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: add mysql.joins metric

# One or more tracking issues related to the change
issues: [14138]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 2 additions & 0 deletions receiver/mysqlreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ These are the metrics available for this scraper.
| **mysql.handlers** | The number of requests to various MySQL handlers. | 1 | Sum(Int) | <ul> <li>handler</li> </ul> |
| **mysql.index.io.wait.count** | The total count of I/O wait events for an index. | 1 | Sum(Int) | <ul> <li>io_waits_operations</li> <li>table_name</li> <li>schema</li> <li>index_name</li> </ul> |
| **mysql.index.io.wait.time** | The total time of I/O wait events for an index. | ns | Sum(Int) | <ul> <li>io_waits_operations</li> <li>table_name</li> <li>schema</li> <li>index_name</li> </ul> |
| **mysql.joins** | The number of joins that perform table scans. | 1 | Sum(Int) | <ul> <li>join_kind</li> </ul> |
| **mysql.locks** | The number of MySQL locks. | 1 | Sum(Int) | <ul> <li>locks</li> </ul> |
| **mysql.log_operations** | The number of InnoDB log operations. | 1 | Sum(Int) | <ul> <li>log_operations</li> </ul> |
| **mysql.operations** | The number of InnoDB operations. | 1 | Sum(Int) | <ul> <li>operations</li> </ul> |
Expand Down Expand Up @@ -58,6 +59,7 @@ metrics:
| handler (kind) | The handler types. | commit, delete, discover, external_lock, mrr_init, prepare, read_first, read_key, read_last, read_next, read_prev, read_rnd, read_rnd_next, rollback, savepoint, savepoint_rollback, update, write |
| index_name (index) | The name of the index. | |
| io_waits_operations (operation) | The io_waits operation type. | delete, fetch, insert, update |
| join_kind (kind) | The kind of join. | full, full_range, range, range_check, scan |
| locks (kind) | The table locks type. | immediate, waited |
| log_operations (operation) | The log operation types. | waits, write_requests, writes |
| operations (operation) | The operation types. | fsyncs, reads, writes |
Expand Down
108 changes: 108 additions & 0 deletions receiver/mysqlreceiver/internal/metadata/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ attributes:
index_name:
value: index
description: The name of the index.
join_kind:
value: kind
description: The kind of join.
enum: [full, full_range, range, range_check, scan]
tmp_resource:
value: resource
description: The kind of temporary resources.
Expand Down Expand Up @@ -283,6 +287,16 @@ metrics:
monotonic: false
aggregation: cumulative
attributes: [threads]
mysql.joins:
enabled: true
description: The number of joins that perform table scans.
unit: 1
sum:
value_type: int
input_type: string
monotonic: true
aggregation: cumulative
attributes: [join_kind]
mysql.tmp_resources:
enabled: true
description: The number of created temporary resources.
Expand Down
12 changes: 12 additions & 0 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
case "Table_locks_waited":
addPartialIfError(errs, m.mb.RecordMysqlLocksDataPoint(now, v, metadata.AttributeLocksWaited))

// joins
case "Select_full_join":
addPartialIfError(errs, m.mb.RecordMysqlJoinsDataPoint(now, v, metadata.AttributeJoinKindFull))
case "Select_full_range_join":
addPartialIfError(errs, m.mb.RecordMysqlJoinsDataPoint(now, v, metadata.AttributeJoinKindFullRange))
case "Select_range":
addPartialIfError(errs, m.mb.RecordMysqlJoinsDataPoint(now, v, metadata.AttributeJoinKindRange))
case "Select_range_check":
addPartialIfError(errs, m.mb.RecordMysqlJoinsDataPoint(now, v, metadata.AttributeJoinKindRangeCheck))
case "Select_scan":
addPartialIfError(errs, m.mb.RecordMysqlJoinsDataPoint(now, v, metadata.AttributeJoinKindScan))

// sorts
case "Sort_merge_passes":
addPartialIfError(errs, m.mb.RecordMysqlSortsDataPoint(now, v, metadata.AttributeSortsMergePasses))
Expand Down
71 changes: 71 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,77 @@
},
"unit": "ns"
},
{
"description": "The number of joins that perform table scans.",
"name": "mysql.joins",
"sum": {
"aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE",
"isMonotonic": true,
"dataPoints": [
{
"asInt": "408",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "full"
}
} ],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "409",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "full_range"
}
} ],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "410",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "range"
}
} ],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "411",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "range_check"
}
} ],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "412",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "scan"
}
} ],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
}
]
},
"unit": "1"
},
{
"description": "The number of created temporary resources.",
"name": "mysql.tmp_resources",
Expand Down