File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,17 @@ import (
18
18
"math"
19
19
"strconv"
20
20
"strings"
21
+ "sync"
21
22
22
23
"github.com/go-kit/kit/log/level"
23
24
"github.com/prometheus/client_golang/prometheus"
24
25
)
25
26
27
+ var (
28
+ // cache the first server setting when there are multiple servers
29
+ shortDescCache sync.Map
30
+ )
31
+
26
32
// Query the pg_settings view containing runtime variables
27
33
func querySettings (ch chan <- prometheus.Metric , server * Server ) error {
28
34
level .Debug (logger ).Log ("msg" , "Querying pg_setting view" , "server" , server )
@@ -46,6 +52,15 @@ func querySettings(ch chan<- prometheus.Metric, server *Server) error {
46
52
return fmt .Errorf ("Error retrieving rows on %q: %s %v" , server , namespace , err )
47
53
}
48
54
55
+ // once the first server setting shortDesc cached, the other server re-use the first cache
56
+ if v , ok := shortDescCache .Load (s .name ); ! ok {
57
+ shortDescCache .Store (s .name , s .shortDesc )
58
+ } else {
59
+ if shortDesc , ok := v .(string ); ok {
60
+ s .shortDesc = shortDesc
61
+ }
62
+ }
63
+
49
64
ch <- s .metric (server .labels )
50
65
}
51
66
You can’t perform that action at this time.
0 commit comments