Skip to content

Commit

Permalink
Merge pull request #41 from BeryJu/fix-panic
Browse files Browse the repository at this point in the history
fix panics when API calls fail
  • Loading branch information
DazWilkin committed Feb 24, 2024
2 parents 6921867 + c4e6c43 commit 8a9d5c9
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions collector/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (c *AccountCollector) Collect(ch chan<- prometheus.Metric) {
account, err := c.client.GetAccount(ctx)
if err != nil {
log.Println(err)
return
}

ch <- prometheus.MustNewConstMetric(
Expand Down
1 change: 1 addition & 0 deletions collector/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (c *InstanceCollector) Collect(ch chan<- prometheus.Metric) {
instances, err := c.client.ListInstances(ctx, nil)
if err != nil {
log.Println(err)
return
}
log.Printf("[InstaneCollector:Collect] len(instances)=%d", len(instances))

Expand Down
1 change: 1 addition & 0 deletions collector/instance_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (c *InstanceStatsCollector) Collect(ch chan<- prometheus.Metric) {
instances, err := c.client.ListInstances(ctx, nil)
if err != nil {
log.Println(err)
return
}
log.Printf("[InstanceStatsCollector:Collect] len(instances)=%d", len(instances))

Expand Down
2 changes: 2 additions & 0 deletions collector/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (c *KubernetesCollector) Collect(ch chan<- prometheus.Metric) {
clusters, err := c.client.ListLKEClusters(ctx, nil)
if err != nil {
log.Println(err)
return
}
log.Printf("[KubernetesCollector:Collect] len(clusters)=%d", len(clusters))

Expand All @@ -73,6 +74,7 @@ func (c *KubernetesCollector) Collect(ch chan<- prometheus.Metric) {
pools, err := c.client.ListLKEClusterPools(ctx, k.ID, nil)
if err != nil {
log.Println(err)
return
}
log.Printf("[KubernetesCollector:Collect] Cluster: %d len(nodepools)=%d", k.ID, len(pools))

Expand Down
1 change: 1 addition & 0 deletions collector/nodebalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (c *NodeBalancerCollector) Collect(ch chan<- prometheus.Metric) {
nodebalancers, err := c.client.ListNodeBalancers(ctx, nil)
if err != nil {
log.Println(err)
return
}
log.Printf("[NodeBalancerCollector:Collect] len(nodebalancers)=%d", len(nodebalancers))

Expand Down
1 change: 1 addition & 0 deletions collector/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (c *TicketCollector) Collect(ch chan<- prometheus.Metric) {
tickets, err := c.client.ListTickets(ctx, nil)
if err != nil {
log.Println(err)
return
}

total := make(map[linodego.TicketStatus]float64)
Expand Down
1 change: 1 addition & 0 deletions collector/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (c *VolumeCollector) Collect(ch chan<- prometheus.Metric) {
volumes, err := c.client.ListVolumes(ctx, nil)
if err != nil {
log.Println(err)
return
}
log.Printf("[VolumeCollector:Collect] len(volumes)=%d", len(volumes))

Expand Down

0 comments on commit 8a9d5c9

Please sign in to comment.