Handle pg_settings names with '.'

This commit is contained in:
Adam Sunderland 2017-04-17 10:33:02 -05:00 committed by Will Rouesnel
parent 98ba566322
commit a87b6bc583
2 changed files with 18 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
"strings"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log" "github.com/prometheus/common/log"
@ -49,7 +50,7 @@ type pgSetting struct {
func (s *pgSetting) metric() prometheus.Metric { func (s *pgSetting) metric() prometheus.Metric {
var ( var (
err error err error
name = s.name name = strings.Replace(s.name, ".", "_", -1)
unit = s.unit unit = s.unit
shortDesc = s.shortDesc shortDesc = s.shortDesc
subsystem = "settings" subsystem = "settings"

View File

@ -124,6 +124,22 @@ var fixtures = []fixture{
d: "Desc{fqName: \"pg_settings_special_minus_one_value_seconds\", help: \"foo foo foo [Units converted to seconds.]\", constLabels: {}, variableLabels: []}", d: "Desc{fqName: \"pg_settings_special_minus_one_value_seconds\", help: \"foo foo foo [Units converted to seconds.]\", constLabels: {}, variableLabels: []}",
v: -1, v: -1,
}, },
fixture{
p: pgSetting{
name: "rds.rds_superuser_reserved_connections",
setting: "2",
unit: "",
shortDesc: "Sets the number of connection slots reserved for rds_superusers.",
vartype: "integer",
},
n: normalised{
val: 2,
unit: "",
err: "",
},
d: "Desc{fqName: \"pg_settings_rds_rds_superuser_reserved_connections\", help: \"Sets the number of connection slots reserved for rds_superusers.\", constLabels: {}, variableLabels: []}",
v: 2,
},
fixture{ fixture{
p: pgSetting{ p: pgSetting{
name: "unknown_unit", name: "unknown_unit",