Enforce stat prefixing at the accumulator layer

This commit is contained in:
Evan Phoenix
2015-05-18 12:15:15 -07:00
parent 34e87e7026
commit f1e1204374
10 changed files with 439 additions and 314 deletions

View File

@@ -50,23 +50,23 @@ type mapping struct {
var mappings = []*mapping{
{
onServer: "Bytes_",
inExport: "mysql_bytes_",
inExport: "bytes_",
},
{
onServer: "Com_",
inExport: "mysql_commands_",
inExport: "commands_",
},
{
onServer: "Handler_",
inExport: "mysql_handler_",
inExport: "handler_",
},
{
onServer: "Innodb_",
inExport: "mysql_innodb_",
inExport: "innodb_",
},
{
onServer: "Threads_",
inExport: "mysql_threads_",
inExport: "threads_",
},
}
@@ -113,14 +113,14 @@ func (m *Mysql) gatherServer(serv *Server, acc plugins.Accumulator) error {
return err
}
acc.Add("mysql_queries", i, nil)
acc.Add("queries", i, nil)
case "Slow_queries":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil {
return err
}
acc.Add("mysql_slow_queries", i, nil)
acc.Add("slow_queries", i, nil)
}
}

View File

@@ -27,16 +27,16 @@ func TestMysqlGeneratesMetrics(t *testing.T) {
prefix string
count int
}{
{"mysql_commands", 141},
{"mysql_handler", 18},
{"mysql_bytes", 2},
{"mysql_innodb", 51},
{"mysql_threads", 4},
{"commands", 141},
{"handler", 18},
{"bytes", 2},
{"innodb", 51},
{"threads", 4},
}
intMetrics := []string{
"mysql_queries",
"mysql_slow_queries",
"queries",
"slow_queries",
}
for _, prefix := range prefixes {