Skip to content

Commit

Permalink
[mysqlreceiver]: add aborted, aborted_clients and locked values…
Browse files Browse the repository at this point in the history
… to `error` property for `mysql.connection.errors` metric (open-telemetry#23211)

Signed-off-by: Dominik Rosiek <[email protected]>
  • Loading branch information
sumo-drosiek committed Jun 12, 2023
1 parent 88ac450 commit 6d35fd7
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .chloggen/drosiek-mysql-aborted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# 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 `aborted`, `aborted_clients` and `locked` values to `error` property for `mysql.connection.errors` metric"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
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: 1 addition & 1 deletion receiver/mysqlreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ Errors that occur during the client connection process.

| Name | Description | Values |
| ---- | ----------- | ------ |
| error | The connection error type. | Str: ``accept``, ``internal``, ``max_connections``, ``peer_address``, ``select``, ``tcpwrap`` |
| error | The connection error type. | Str: ``accept``, ``internal``, ``max_connections``, ``peer_address``, ``select``, ``tcpwrap``, ``aborted``, ``aborted_clients``, ``locked`` |

### mysql.joins

Expand Down
12 changes: 12 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.

2 changes: 1 addition & 1 deletion receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ attributes:
name_override: error
description: The connection error type.
type: string
enum: [accept, internal, max_connections, peer_address, select, tcpwrap]
enum: [accept, internal, max_connections, peer_address, select, tcpwrap, aborted, aborted_clients, locked]
handler:
name_override: kind
description: The handler types.
Expand Down
16 changes: 11 additions & 5 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ 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.AttributeDirectionReceived))
Expand Down Expand Up @@ -186,6 +185,17 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
case "Connection_errors_tcpwrap":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorTcpwrap))
case "Aborted_clients":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorAbortedClients))
case "Aborted_connects":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorAborted))
case "Locked_connects":
addPartialIfError(errs, m.mb.RecordMysqlLockedConnectsDataPoint(now, v))
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorLocked))

// connection
case "Connections":
addPartialIfError(errs, m.mb.RecordMysqlConnectionCountDataPoint(now, v))
Expand Down Expand Up @@ -322,10 +332,6 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
case "Table_locks_waited":
addPartialIfError(errs, m.mb.RecordMysqlLocksDataPoint(now, v, metadata.AttributeLocksWaited))

// locked_connects
case "Locked_connects":
addPartialIfError(errs, m.mb.RecordMysqlLockedConnectsDataPoint(now, v))

// joins
case "Select_full_join":
addPartialIfError(errs, m.mb.RecordMysqlJoinsDataPoint(now, v, metadata.AttributeJoinKindFull))
Expand Down
21 changes: 21 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,27 @@ resourceMetrics:
stringValue: tcpwrap
startTimeUnixNano: "1644862687825728000"
timeUnixNano: "1644862687825772000"
- asInt: "2"
attributes:
- key: error
value:
stringValue: aborted
startTimeUnixNano: "1644862687825728000"
timeUnixNano: "1644862687825772000"
- asInt: "1"
attributes:
- key: error
value:
stringValue: aborted_clients
startTimeUnixNano: "1644862687825728000"
timeUnixNano: "1644862687825772000"
- asInt: "293"
attributes:
- key: error
value:
stringValue: locked
startTimeUnixNano: "1644862687825728000"
timeUnixNano: "1644862687825772000"
isMonotonic: true
unit: "1"
- description: The number of writes to the InnoDB doublewrite buffer.
Expand Down

0 comments on commit 6d35fd7

Please sign in to comment.