From 634694332961327c63f34760bb5a756af53e419e Mon Sep 17 00:00:00 2001 From: Adam Sunderland Date: Mon, 17 Apr 2017 10:33:02 -0500 Subject: [PATCH] Handle pg_settings names with '.' --- pg_setting.go | 3 ++- pg_setting_test.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pg_setting.go b/pg_setting.go index ca268ad8d..4a59a8307 100644 --- a/pg_setting.go +++ b/pg_setting.go @@ -6,6 +6,7 @@ import ( "fmt" "math" "strconv" + "strings" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" @@ -49,7 +50,7 @@ type pgSetting struct { func (s *pgSetting) metric() prometheus.Metric { var ( err error - name = s.name + name = strings.Replace(s.name, ".", "_", -1) unit = s.unit shortDesc = s.shortDesc subsystem = "settings" diff --git a/pg_setting_test.go b/pg_setting_test.go index 18c307803..198b88204 100644 --- a/pg_setting_test.go +++ b/pg_setting_test.go @@ -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: []}", 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{ p: pgSetting{ name: "unknown_unit",