Skip to content

Commit

Permalink
Merge b9d1037 into dc67066
Browse files Browse the repository at this point in the history
  • Loading branch information
miroswan committed Dec 5, 2018
2 parents dc67066 + b9d1037 commit 9f1b1a4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/writer/sonar.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (

// Sonar writes metrics to DigitalOcean sonar
type Sonar struct {
client tsclient.Client
client tsclient.Client
firstWriteSent bool
}

// NewSonar creates a new Sonar writer
func NewSonar(client tsclient.Client) *Sonar {
return &Sonar{
client: client,
client: client,
firstWriteSent: false,
}
}

Expand Down Expand Up @@ -47,8 +49,13 @@ func (s *Sonar) Write(mets []*dto.MetricFamily) error {
}

}

return s.client.Flush()
err := s.client.Flush()
httpError, ok := err.(*tsclient.UnexpectedHTTPStatusError)
if !s.firstWriteSent && ok && httpError.StatusCode == 429 {
err = nil
}
s.firstWriteSent = true
return err
}

// Name is the name of this writer
Expand Down

0 comments on commit 9f1b1a4

Please sign in to comment.