@@ -11,6 +11,9 @@ import (
1111 "strconv"
1212 "strings"
1313
14+ "golang.org/x/text/cases"
15+ "golang.org/x/text/language"
16+
1417 mp "github.com/mackerelio/go-mackerel-plugin"
1518 // MySQL Driver
1619 "github.com/go-sql-driver/mysql"
@@ -47,12 +50,12 @@ func init() {
4750}
4851
4952func (m * MySQLPlugin ) defaultGraphdef () map [string ]mp.Graphs {
50- labelPrefix := strings .Title (strings .Replace (m .MetricKeyPrefix (), "mysql" , "MySQL" , - 1 ))
53+ labelPrefix := cases .Title ( language . Und , cases . NoLower ). String (strings .Replace (m .MetricKeyPrefix (), "mysql" , "MySQL" , - 1 ))
5154
5255 capacityMetrics := []mp.Metrics {
5356 {Name : "PercentageOfConnections" , Label : "Percentage Of Connections" , Diff : false , Stacked : false },
5457 }
55- if m .DisableInnoDB != true {
58+ if ! m .DisableInnoDB {
5659 capacityMetrics = append (capacityMetrics , mp.Metrics {
5760 Name : "PercentageOfBufferPool" , Label : "Percentage Of Buffer Pool" , Diff : false , Stacked : false ,
5861 })
@@ -191,7 +194,7 @@ func (m *MySQLPlugin) fetchVersion(db *sql.DB) (version [3]int, err error) {
191194 version [2 ], _ = strconv .Atoi (xs [2 ])
192195 }
193196 }
194- break
197+ break //nolint
195198 }
196199 if version [0 ] == 0 {
197200 err = errors .New ("failed to get mysql version" )
@@ -371,7 +374,7 @@ func (m *MySQLPlugin) convertInnodbStats(stat map[string]float64) {
371374
372375func (m * MySQLPlugin ) calculateCapacity (stat map [string ]float64 ) {
373376 stat ["PercentageOfConnections" ] = 100.0 * stat ["Threads_connected" ] / stat ["max_connections" ]
374- if m .DisableInnoDB != true {
377+ if ! m .DisableInnoDB {
375378 stat ["PercentageOfBufferPool" ] = 100.0 * stat ["database_pages" ] / stat ["pool_size" ]
376379 }
377380}
@@ -415,7 +418,7 @@ func (m *MySQLPlugin) FetchMetrics() (map[string]float64, error) {
415418 return nil , err
416419 }
417420
418- if m .DisableInnoDB != true {
421+ if ! m .DisableInnoDB {
419422 m .convertInnodbStats (stat )
420423 if ! m .isAuroraReader {
421424 err := m .fetchShowInnodbStatus (db , stat )
@@ -475,7 +478,7 @@ func (m *MySQLPlugin) GraphDefinition() map[string]mp.Graphs {
475478}
476479
477480func (m * MySQLPlugin ) addGraphdefWithInnoDBMetrics (graphdef map [string ]mp.Graphs ) map [string ]mp.Graphs {
478- labelPrefix := strings .Title (strings .Replace (m .MetricKeyPrefix (), "mysql" , "MySQL" , - 1 ))
481+ labelPrefix := cases .Title ( language . Und , cases . NoLower ). String (strings .Replace (m .MetricKeyPrefix (), "mysql" , "MySQL" , - 1 ))
479482 graphdef ["innodb_rows" ] = mp.Graphs {
480483 Label : labelPrefix + " innodb Rows" ,
481484 Unit : "float" ,
@@ -666,8 +669,7 @@ func (m *MySQLPlugin) addGraphdefWithInnoDBMetrics(graphdef map[string]mp.Graphs
666669}
667670
668671func (m * MySQLPlugin ) addExtendedGraphdef (graphdef map [string ]mp.Graphs ) map [string ]mp.Graphs {
669- //TODO
670- labelPrefix := strings .Title (strings .Replace (m .MetricKeyPrefix (), "mysql" , "MySQL" , - 1 ))
672+ labelPrefix := cases .Title (language .Und , cases .NoLower ).String (strings .Replace (m .MetricKeyPrefix (), "mysql" , "MySQL" , - 1 ))
671673 graphdef ["query_cache" ] = mp.Graphs {
672674 Label : labelPrefix + " query Cache" ,
673675 Unit : "float" ,
0 commit comments