From 6d35fd7ac648b2401924a61be7fa0f95087a1d62 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek <58699848+sumo-drosiek@users.noreply.github.com> Date: Mon, 12 Jun 2023 16:33:47 +0200 Subject: [PATCH] [mysqlreceiver]: add `aborted`, `aborted_clients` and `locked` values to `error` property for `mysql.connection.errors` metric (#23211) Signed-off-by: Dominik Rosiek --- .chloggen/drosiek-mysql-aborted.yaml | 20 ++++++++++++++++++ receiver/mysqlreceiver/documentation.md | 2 +- .../internal/metadata/generated_metrics.go | 12 +++++++++++ receiver/mysqlreceiver/metadata.yaml | 2 +- receiver/mysqlreceiver/scraper.go | 16 +++++++++----- .../testdata/scraper/expected.yaml | 21 +++++++++++++++++++ 6 files changed, 66 insertions(+), 7 deletions(-) create mode 100755 .chloggen/drosiek-mysql-aborted.yaml diff --git a/.chloggen/drosiek-mysql-aborted.yaml b/.chloggen/drosiek-mysql-aborted.yaml new file mode 100755 index 000000000000..bb48a9d4c8f2 --- /dev/null +++ b/.chloggen/drosiek-mysql-aborted.yaml @@ -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: diff --git a/receiver/mysqlreceiver/documentation.md b/receiver/mysqlreceiver/documentation.md index 81194a7c30ec..9e697a71505f 100644 --- a/receiver/mysqlreceiver/documentation.md +++ b/receiver/mysqlreceiver/documentation.md @@ -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 diff --git a/receiver/mysqlreceiver/internal/metadata/generated_metrics.go b/receiver/mysqlreceiver/internal/metadata/generated_metrics.go index 5974c03026ea..b9ee44b34e8e 100644 --- a/receiver/mysqlreceiver/internal/metadata/generated_metrics.go +++ b/receiver/mysqlreceiver/internal/metadata/generated_metrics.go @@ -190,6 +190,9 @@ const ( AttributeConnectionErrorPeerAddress AttributeConnectionErrorSelect AttributeConnectionErrorTcpwrap + AttributeConnectionErrorAborted + AttributeConnectionErrorAbortedClients + AttributeConnectionErrorLocked ) // String returns the string representation of the AttributeConnectionError. @@ -207,6 +210,12 @@ func (av AttributeConnectionError) String() string { return "select" case AttributeConnectionErrorTcpwrap: return "tcpwrap" + case AttributeConnectionErrorAborted: + return "aborted" + case AttributeConnectionErrorAbortedClients: + return "aborted_clients" + case AttributeConnectionErrorLocked: + return "locked" } return "" } @@ -219,6 +228,9 @@ var MapAttributeConnectionError = map[string]AttributeConnectionError{ "peer_address": AttributeConnectionErrorPeerAddress, "select": AttributeConnectionErrorSelect, "tcpwrap": AttributeConnectionErrorTcpwrap, + "aborted": AttributeConnectionErrorAborted, + "aborted_clients": AttributeConnectionErrorAbortedClients, + "locked": AttributeConnectionErrorLocked, } // AttributeConnectionStatus specifies the a value connection_status attribute. diff --git a/receiver/mysqlreceiver/metadata.yaml b/receiver/mysqlreceiver/metadata.yaml index dbf66f19aa30..a4527e1a1b33 100644 --- a/receiver/mysqlreceiver/metadata.yaml +++ b/receiver/mysqlreceiver/metadata.yaml @@ -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. diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index d9318964a3d7..7b2000c363f4 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -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)) @@ -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)) @@ -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)) diff --git a/receiver/mysqlreceiver/testdata/scraper/expected.yaml b/receiver/mysqlreceiver/testdata/scraper/expected.yaml index 05c8539c840a..6690f17c8ada 100644 --- a/receiver/mysqlreceiver/testdata/scraper/expected.yaml +++ b/receiver/mysqlreceiver/testdata/scraper/expected.yaml @@ -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.