diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index f71a75df3292..05266eee0b42 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -444,10 +444,23 @@ func (c *mySQLClient) getStatementEventsStats() ([]StatementEventStats, error) { var stats []StatementEventStats for rows.Next() { var s StatementEventStats - err := rows.Scan(&s.schema, &s.digest, &s.digestText, - &s.sumTimerWait, &s.countErrors, &s.countWarnings, - &s.countRowsAffected, &s.countRowsSent, &s.countRowsExamined, &s.countCreatedTmpDiskTables, - &s.countCreatedTmpTables, &s.countSortMergePasses, &s.countSortRows, &s.countNoIndexUsed, &s.countStar) + err := rows.Scan( + &s.schema, + &s.digest, + &s.digestText, + &s.sumTimerWait, + &s.countErrors, + &s.countWarnings, + &s.countRowsAffected, + &s.countRowsSent, + &s.countRowsExamined, + &s.countCreatedTmpDiskTables, + &s.countCreatedTmpTables, + &s.countSortMergePasses, + &s.countSortRows, + &s.countNoIndexUsed, + &s.countStar, + ) if err != nil { return nil, err } diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index c0e5e1a7c899..7df99256d5ee 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -559,7 +559,6 @@ func (m *mySQLScraper) scrapeStatementEventsStats(now pcommon.Timestamp, errs *s errs.AddPartial(8, err) return } - for i := 0; i < len(statementEventsStats); i++ { s := statementEventsStats[i] m.mb.RecordMysqlStatementEventCountDataPoint(now, s.countCreatedTmpDiskTables, s.schema, s.digest, s.digestText, metadata.AttributeEventStateCreatedTmpDiskTables) diff --git a/receiver/mysqlreceiver/scraper_test.go b/receiver/mysqlreceiver/scraper_test.go index e32f45a3d020..c674906d6138 100644 --- a/receiver/mysqlreceiver/scraper_test.go +++ b/receiver/mysqlreceiver/scraper_test.go @@ -135,7 +135,7 @@ func TestScrape(t *testing.T) { require.True(t, errors.As(scrapeErr, &partialError), "returned error was not PartialScrapeError") // 5 comes from 4 failed "must-have" metrics that aren't present, // and the other failure comes from a row that fails to parse as a number - require.Equal(t, partialError.Failed, 5, "Expected partial error count to be 5") + require.Equal(t, partialError.Failed, 7, "Expected partial error count to be 5") }) } diff --git a/receiver/mysqlreceiver/testdata/scraper/expected_partial.yaml b/receiver/mysqlreceiver/testdata/scraper/expected_partial.yaml index 82bd5d6069f8..475b64064057 100644 --- a/receiver/mysqlreceiver/testdata/scraper/expected_partial.yaml +++ b/receiver/mysqlreceiver/testdata/scraper/expected_partial.yaml @@ -4,6 +4,9 @@ resourceMetrics: - key: mysql.instance.endpoint value: stringValue: localhost:3306 + - key: mysql.db.version + value: + stringValue: "8.0.27" scopeMetrics: - metrics: - description: The number of pages in the InnoDB buffer pool. diff --git a/receiver/mysqlreceiver/testdata/scraper/total_errors_empty b/receiver/mysqlreceiver/testdata/scraper/total_errors_empty new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/receiver/mysqlreceiver/testdata/scraper/total_rows_empty b/receiver/mysqlreceiver/testdata/scraper/total_rows_empty new file mode 100644 index 000000000000..e69de29bb2d1