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

@@ -100,21 +100,21 @@ func (p *Postgresql) accRow(row scanner, acc plugins.Accumulator) error {
tags := map[string]string{"db": name}
acc.Add("postgresql_xact_commit", commit, tags)
acc.Add("postgresql_xact_rollback", rollback, tags)
acc.Add("postgresql_blks_read", read, tags)
acc.Add("postgresql_blks_hit", hit, tags)
acc.Add("postgresql_tup_returned", returned, tags)
acc.Add("postgresql_tup_fetched", fetched, tags)
acc.Add("postgresql_tup_inserted", inserted, tags)
acc.Add("postgresql_tup_updated", updated, tags)
acc.Add("postgresql_tup_deleted", deleted, tags)
acc.Add("postgresql_conflicts", conflicts, tags)
acc.Add("postgresql_temp_files", temp_files, tags)
acc.Add("postgresql_temp_bytes", temp_bytes, tags)
acc.Add("postgresql_deadlocks", deadlocks, tags)
acc.Add("postgresql_blk_read_time", read_time, tags)
acc.Add("postgresql_blk_write_time", read_time, tags)
acc.Add("xact_commit", commit, tags)
acc.Add("xact_rollback", rollback, tags)
acc.Add("blks_read", read, tags)
acc.Add("blks_hit", hit, tags)
acc.Add("tup_returned", returned, tags)
acc.Add("tup_fetched", fetched, tags)
acc.Add("tup_inserted", inserted, tags)
acc.Add("tup_updated", updated, tags)
acc.Add("tup_deleted", deleted, tags)
acc.Add("conflicts", conflicts, tags)
acc.Add("temp_files", temp_files, tags)
acc.Add("temp_bytes", temp_bytes, tags)
acc.Add("deadlocks", deadlocks, tags)
acc.Add("blk_read_time", read_time, tags)
acc.Add("blk_write_time", read_time, tags)
return nil
}

View File

@@ -24,24 +24,24 @@ func TestPostgresqlGeneratesMetrics(t *testing.T) {
require.NoError(t, err)
intMetrics := []string{
"postgresql_xact_commit",
"postgresql_xact_rollback",
"postgresql_blks_read",
"postgresql_blks_hit",
"postgresql_tup_returned",
"postgresql_tup_fetched",
"postgresql_tup_inserted",
"postgresql_tup_updated",
"postgresql_tup_deleted",
"postgresql_conflicts",
"postgresql_temp_files",
"postgresql_temp_bytes",
"postgresql_deadlocks",
"xact_commit",
"xact_rollback",
"blks_read",
"blks_hit",
"tup_returned",
"tup_fetched",
"tup_inserted",
"tup_updated",
"tup_deleted",
"conflicts",
"temp_files",
"temp_bytes",
"deadlocks",
}
floatMetrics := []string{
"postgresql_blk_read_time",
"postgresql_blk_write_time",
"blk_read_time",
"blk_write_time",
}
for _, metric := range intMetrics {
@@ -68,7 +68,7 @@ func TestPostgresqlTagsMetricsWithDatabaseName(t *testing.T) {
err := p.Gather(&acc)
require.NoError(t, err)
point, ok := acc.Get("postgresql_xact_commit")
point, ok := acc.Get("xact_commit")
require.True(t, ok)
assert.Equal(t, "postgres", point.Tags["db"])
@@ -91,7 +91,7 @@ func TestPostgresqlDefaultsToAllDatabases(t *testing.T) {
var found bool
for _, pnt := range acc.Points {
if pnt.Name == "postgresql_xact_commit" {
if pnt.Name == "xact_commit" {
if pnt.Tags["db"] == "postgres" {
found = true
break