Skip to content

Commit

Permalink
extended test: scrape has partial failure
Browse files Browse the repository at this point in the history
  • Loading branch information
naman47vyas committed Jul 3, 2024
1 parent b14633a commit 684078f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
21 changes: 17 additions & 4 deletions receiver/mysqlreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion receiver/mysqlreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

}
Expand Down
3 changes: 3 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected_partial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Empty file.
Empty file.

0 comments on commit 684078f

Please sign in to comment.