Skip to content

Commit

Permalink
allow perf_schema.memory summary current_bytes to be negative
Browse files Browse the repository at this point in the history
  • Loading branch information
dafydd-t committed Nov 19, 2020
1 parent 44a8301 commit ac3bbd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion collector/perf_schema_memory_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (ScrapePerfMemoryEvents) Scrape(ctx context.Context, db *sql.DB, ch chan<-
eventName string
bytesAlloc uint64
bytesFree uint64
currentBytes uint64
currentBytes int64
)

for perfSchemaMemoryEventsRows.Next() {
Expand Down
4 changes: 4 additions & 0 deletions collector/perf_schema_memory_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestScrapePerfMemoryEvents(t *testing.T) {

rows := sqlmock.NewRows(columns).
AddRow("memory/innodb/event1", "1001", "500", "501").
AddRow("memory/performance_schema/event1", "6000", "7", "-83904").
AddRow("memory/innodb/event2", "2002", "1000", "1002").
AddRow("memory/sql/event1", "30", "4", "26")
mock.ExpectQuery(sanitizeQuery(perfMemoryEventsQuery)).WillReturnRows(rows)
Expand All @@ -63,6 +64,9 @@ func TestScrapePerfMemoryEvents(t *testing.T) {
{labels: labelMap{"event_name": "innodb/event1"}, value: 1001, metricType: dto.MetricType_COUNTER},
{labels: labelMap{"event_name": "innodb/event1"}, value: 500, metricType: dto.MetricType_COUNTER},
{labels: labelMap{"event_name": "innodb/event1"}, value: 501, metricType: dto.MetricType_GAUGE},
{labels: labelMap{"event_name": "performance_schema/event1"}, value: 6000, metricType: dto.MetricType_COUNTER},
{labels: labelMap{"event_name": "performance_schema/event1"}, value: 7, metricType: dto.MetricType_COUNTER},
{labels: labelMap{"event_name": "performance_schema/event1"}, value: -83904, metricType: dto.MetricType_GAUGE},
{labels: labelMap{"event_name": "innodb/event2"}, value: 2002, metricType: dto.MetricType_COUNTER},
{labels: labelMap{"event_name": "innodb/event2"}, value: 1000, metricType: dto.MetricType_COUNTER},
{labels: labelMap{"event_name": "innodb/event2"}, value: 1002, metricType: dto.MetricType_GAUGE},
Expand Down

0 comments on commit ac3bbd4

Please sign in to comment.