Skip to content

Commit a87b6bc

Browse files
iterionwrouesnel
authored andcommitted
Handle pg_settings names with '.'
1 parent 98ba566 commit a87b6bc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

pg_setting.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"math"
88
"strconv"
9+
"strings"
910

1011
"github.com/prometheus/client_golang/prometheus"
1112
"github.com/prometheus/common/log"
@@ -49,7 +50,7 @@ type pgSetting struct {
4950
func (s *pgSetting) metric() prometheus.Metric {
5051
var (
5152
err error
52-
name = s.name
53+
name = strings.Replace(s.name, ".", "_", -1)
5354
unit = s.unit
5455
shortDesc = s.shortDesc
5556
subsystem = "settings"

pg_setting_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ var fixtures = []fixture{
124124
d: "Desc{fqName: \"pg_settings_special_minus_one_value_seconds\", help: \"foo foo foo [Units converted to seconds.]\", constLabels: {}, variableLabels: []}",
125125
v: -1,
126126
},
127+
fixture{
128+
p: pgSetting{
129+
name: "rds.rds_superuser_reserved_connections",
130+
setting: "2",
131+
unit: "",
132+
shortDesc: "Sets the number of connection slots reserved for rds_superusers.",
133+
vartype: "integer",
134+
},
135+
n: normalised{
136+
val: 2,
137+
unit: "",
138+
err: "",
139+
},
140+
d: "Desc{fqName: \"pg_settings_rds_rds_superuser_reserved_connections\", help: \"Sets the number of connection slots reserved for rds_superusers.\", constLabels: {}, variableLabels: []}",
141+
v: 2,
142+
},
127143
fixture{
128144
p: pgSetting{
129145
name: "unknown_unit",

0 commit comments

Comments
 (0)