Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: allow perf_schema.memory summary current_bytes to be negative #517

Merged
merged 1 commit into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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