Skip to content

Commit

Permalink
Rename metric to replication_group_member_info, avoid unnecessary ite…
Browse files Browse the repository at this point in the history
…ration, remove duplicate comment

Signed-off-by: Nir Gilboa <[email protected]>
  • Loading branch information
nirgilboa committed Apr 13, 2020
1 parent 781df29 commit 20e683f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
16 changes: 5 additions & 11 deletions collector/perf_schema_replication_group_members.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,19 @@ func (ScrapePerfReplicationGroupMembers) Scrape(ctx context.Context, db *sql.DB,
return err
}

var labelNames = make([]string, len(columnNames))
var values = make([]string, len(columnNames))
for i := range columnNames {
for i, columnName := range columnNames {
labelNames[i] = strings.ToLower(columnName)
values[i] = string(*scanArgs[i].(*sql.RawBytes))
}

var performanceSchemaReplicationGroupMembersMemberDesc = prometheus.NewDesc(
prometheus.BuildFQName(namespace, performanceSchema, "replication_group_member"),
prometheus.BuildFQName(namespace, performanceSchema, "replication_group_member_info"),
"Information about the replication group member: "+
"channel_name, member_id, member_host, member_port, member_state. "+
"(member_role and member_version where available)",
toLowerCase(columnNames), nil,
labelNames, nil,
)

ch <- prometheus.MustNewConstMetric(performanceSchemaReplicationGroupMembersMemberDesc,
Expand All @@ -86,13 +88,5 @@ func (ScrapePerfReplicationGroupMembers) Scrape(ctx context.Context, db *sql.DB,

}

func toLowerCase(original []string) []string {
lowerCase := make([]string, len(original))
for i, v := range original {
lowerCase[i] = strings.ToLower(v)
}
return lowerCase
}

// check interface
var _ Scraper = ScrapePerfReplicationGroupMembers{}
1 change: 0 additions & 1 deletion collector/perf_schema_replication_group_members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func TestScrapePerfReplicationGroupMembers(t *testing.T) {
}
})

// Ensure all SQL queries were executed.
// Ensure all SQL queries were executed.
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled exceptions: %s", err)
Expand Down

0 comments on commit 20e683f

Please sign in to comment.