Skip to content

Commit

Permalink
fix: don't try to return metrics after collection error (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickeasters authored Jan 17, 2023
1 parent 30d5a04 commit f28a4a4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/collector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (c *clientCollector) Collect(ch chan<- prometheus.Metric) {
clients, err := client.GetClients()
if err != nil {
log.Error().Err(err).Msg("Failed to get clients")
return
}

ch <- prometheus.MustNewConstMetric(c.omadaClientConnectedTotal, prometheus.GaugeValue, float64(len(clients)),
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (c *controllerCollector) Collect(ch chan<- prometheus.Metric) {
controller, err := client.GetController()
if err != nil {
log.Error().Err(err).Msg("Failed to get controller")
return
}

ch <- prometheus.MustNewConstMetric(c.omadaControllerUptimeSeconds, prometheus.GaugeValue, controller.Uptime/1000,
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (c *deviceCollector) Collect(ch chan<- prometheus.Metric) {
devices, err := client.GetDevices()
if err != nil {
log.Error().Err(err).Msg("Failed to get devices")
return
}

for _, item := range devices {
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func (c *portCollector) Collect(ch chan<- prometheus.Metric) {
devices, err := client.GetDevices()
if err != nil {
log.Error().Err(err).Msg("Failed to get devices")
return
}

for _, device := range devices {
Expand Down

0 comments on commit f28a4a4

Please sign in to comment.