Skip to content

Commit af34eba

Browse files
committed
Improve Verbosity of queryNamespaceMappings Errors
Previously if any errors were encountered by queryNamespaceMappings, only a count of those errors was returned - making debugging those errors harder than it needs to be. I'm changing this to immediately return nil if no errors are encountered, and otherwise an error will be formatted with each of the namespaces and what the error was for that namespace. Signed-off-by: Jonathan Bowe <[email protected]>
1 parent 295cab3 commit af34eba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/postgres_exporter/server.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ func (s *Server) Scrape(ch chan<- prometheus.Metric, disableSettingsMetrics bool
124124
}
125125

126126
errMap := queryNamespaceMappings(ch, s)
127-
if len(errMap) > 0 {
128-
err = fmt.Errorf("queryNamespaceMappings returned %d errors", len(errMap))
127+
if len(errMap) == 0 {
128+
return nil
129+
}
130+
err = fmt.Errorf("queryNamespaceMappings errors encountered")
131+
for namespace, errStr := range errMap {
132+
err = fmt.Errorf("%s, %s namespace had the following error: %s", err, namespace, errStr)
129133
}
130134

131135
return err

0 commit comments

Comments
 (0)