Skip to content

Commit 0c0a5e1

Browse files
author
Jonathan Bowe
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.
1 parent decdbb5 commit 0c0a5e1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cmd/postgres_exporter/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ 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+
for namespace, errStr := range errMap {
131+
err = fmt.Errorf("%s\nqueryNamespaceMappings error for the %s namespace: %s", err, namespace, errStr)
129132
}
130133

131134
return err

0 commit comments

Comments
 (0)