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.client.network.io metric #14744

Closed
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-bytes.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.client.network.io 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 @@ -14,6 +14,7 @@ These are the metrics available for this scraper.
| **mysql.buffer_pool.page_flushes** | The number of requests to flush pages from the InnoDB buffer pool. | 1 | Sum(Int) | <ul> </ul> |
| **mysql.buffer_pool.pages** | The number of pages in the InnoDB buffer pool. | 1 | Sum(Int) | <ul> <li>buffer_pool_pages</li> </ul> |
| **mysql.buffer_pool.usage** | The number of bytes in the InnoDB buffer pool. | By | Sum(Int) | <ul> <li>buffer_pool_data</li> </ul> |
| **mysql.client.network.io** | The number of transmitted bytes between server and clients. | By | Sum(Int) | <ul> <li>transmission_direction</li> </ul> |
| **mysql.commands** | The number of times each type of command has been executed. | 1 | Sum(Int) | <ul> <li>command</li> </ul> |
| **mysql.double_writes** | The number of writes to the InnoDB doublewrite buffer. | 1 | Sum(Int) | <ul> <li>double_writes</li> </ul> |
| **mysql.handlers** | The number of requests to various MySQL handlers. | 1 | Sum(Int) | <ul> <li>handler</li> </ul> |
Expand Down Expand Up @@ -79,3 +80,4 @@ metrics:
| table_name (table) | Table name for event or process. | |
| threads (kind) | The thread count type. | cached, connected, created, running |
| tmp_resource (resource) | The kind of temporary resources. | disk_tables, files, tables |
| transmission_direction (kind) | The name of the transmission direction. | received, sent |
96 changes: 96 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.
transmission_direction:
value: kind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this should be direction

Copy link
Member Author

@sumo-drosiek sumo-drosiek Oct 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added fixed code as part of #15366

description: The name of the transmission direction.
enum: [received, sent]
digest:
value: digest
description: Digest.
Expand Down Expand Up @@ -301,6 +305,16 @@ metrics:
monotonic: false
aggregation: cumulative
attributes: [threads]
mysql.client.network.io:
enabled: true
description: The number of transmitted bytes between server and clients.
unit: By
sum:
value_type: int
input_type: string
monotonic: true
aggregation: cumulative
attributes: [transmission_direction]
mysql.opened_resources:
enabled: true
description: The number of opened resources.
Expand Down
6 changes: 6 additions & 0 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
for k, v := range globalStats {
switch k {

// bytes transmission
case "Bytes_received":
addPartialIfError(errs, m.mb.RecordMysqlClientNetworkIoDataPoint(now, v, metadata.AttributeTransmissionDirectionReceived))
case "Bytes_sent":
addPartialIfError(errs, m.mb.RecordMysqlClientNetworkIoDataPoint(now, v, metadata.AttributeTransmissionDirectionSent))

// buffer_pool.pages
case "Innodb_buffer_pool_pages_data":
addPartialIfError(errs, m.mb.RecordMysqlBufferPoolPagesDataPoint(now, v,
Expand Down
37 changes: 37 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,43 @@
},
"unit": "ns"
},
{
"description": "The number of transmitted bytes between server and clients.",
"name": "mysql.client.network.io",
"sum": {
"aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE",
"dataPoints": [
{
"asInt": "8",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "received"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "9",
"attributes": [
{
"key": "kind",
"value": {
"stringValue": "sent"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
}
],
"isMonotonic": true
},
"unit": "By"
},
{
"description": "Summary of current and recent statement events.",
"name": "mysql.statement_event.count",
Expand Down