Skip to content

Commit

Permalink
Improve log messages on initial fetch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbub committed Nov 10, 2024
1 parent 2baef16 commit 690d2c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/collector/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,18 @@ func (e *Exporter) buildLabels(inverterSN string) prometheus.Labels {
func (e *Exporter) fetchInvertersInitial(ctx context.Context) ([]metricData, error) {
data, err := e.fetchInverters(ctx)
if err != nil {
// in case initial fetch fails on timeout, we want the program to continue
// in case initial fetch fails on context error (timeout, cancel), we want the program to continue
// the next tick will retry the fetch instead of exiting the program
if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
e.log.Error("initial inverter fetch context error", zap.Error(err))
return data, nil
}

// in case initial fetch fails on rate limit, we want the program to continue
// the next tick will retry the fetch instead of exiting the program
var errRate *foxesscloud.RateLimitExceededError
if errors.As(err, &errRate) {
e.log.Error("rate limit exceeded", zap.Error(err))
e.log.Error("initial inverter fetch rate limit exceeded", zap.Error(err))
return data, nil
}
return nil, err
Expand Down

0 comments on commit 690d2c9

Please sign in to comment.