Skip to content

Commit

Permalink
Start up OK even if api.fastly.com is unreachable (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon authored Jan 8, 2022
1 parent 1e1277d commit 01211fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions cmd/fastly-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,20 @@ func main() {
}

{
g, ctx := errgroup.WithContext(context.Background())
g.Go(func() error { return serviceCache.Refresh(ctx) })
g.Go(func() error { return datacenterCache.Refresh(ctx) })
if err := g.Wait(); err != nil {
level.Error(apiLogger).Log("during", "initial API calls", "err", err)
os.Exit(1)
}
var g errgroup.Group
g.Go(func() error {
if err := serviceCache.Refresh(context.Background()); err != nil {
level.Warn(logger).Log("during", "initial fetch of service IDs", "err", err, "msg", "service metrics unavailable, will retry")
}
return nil
})
g.Go(func() error {
if err := datacenterCache.Refresh(context.Background()); err != nil {
level.Warn(logger).Log("during", "initial fetch of datacenters", "err", err, "msg", "datacenter labels unavailable, will retry")
}
return nil
})
g.Wait()
}

var defaultGatherers prometheus.Gatherers
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewError(resp *http.Response) *Error {
// Error implements the error interface.
func (e *Error) Error() string {
var sb strings.Builder
sb.WriteString("api.fastly.com responded with")
sb.WriteString("api.fastly.com responded with ")
sb.WriteString(http.StatusText(e.Code))
if e.Msg != "" {
sb.WriteString(" (" + e.Msg + ")")
Expand Down

0 comments on commit 01211fb

Please sign in to comment.