Skip to content

Commit

Permalink
Remove some dependencies, fix up scripts (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbourgon authored Jun 21, 2021
1 parent 90fd316 commit 0d554a3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cmd/fastly-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"text/tabwriter"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/oklog/run"
"github.com/peterbourgon/fastly-exporter/pkg/api"
"github.com/peterbourgon/fastly-exporter/pkg/filter"
Expand Down
4 changes: 2 additions & 2 deletions fieldgen.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env fish

cd cmd/fieldgen ; \
and go run main.go > ../../pkg/gen/gen.go ; \
and gofmt -w ../../pkg/gen/gen.go ; \
go run main.go > ../../pkg/gen/gen.go
gofmt -w ../../pkg/gen/gen.go
cd -
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ go 1.12

require (
github.com/cespare/xxhash v1.1.0
github.com/go-kit/kit v0.9.0
github.com/go-kit/log v0.1.0
github.com/google/go-cmp v0.5.5
github.com/json-iterator/go v1.1.11
github.com/oklog/run v1.0.0
github.com/peterbourgon/ff/v3 v3.0.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/spaolacci/murmur3 v1.1.0 // indirect
)
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0 h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
Expand Down Expand Up @@ -79,7 +79,6 @@ github.com/peterbourgon/ff/v3 v3.0.0 h1:eQzEmNahuOjQXfuegsKQTSTDbf4dNvr/eNLrmJhi
github.com/peterbourgon/ff/v3 v3.0.0/go.mod h1:UILIFjRH5a/ar8TjXYLTkIvSvekZqPm5Eb/qbGk6CT0=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
15 changes: 6 additions & 9 deletions pkg/api/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
"time"

"github.com/cespare/xxhash"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/peterbourgon/fastly-exporter/pkg/filter"
"github.com/pkg/errors"
)

// HTTPClient is a consumer contract for the cache.
Expand Down Expand Up @@ -96,14 +95,14 @@ func (c *Cache) Refresh(client HTTPClient) error {

req, err := http.NewRequest("GET", "https://api.fastly.com/service", nil)
if err != nil {
return errors.Wrap(err, "error constructing API services request")
return fmt.Errorf("error constructing API services request: %w", err)
}

req.Header.Set("Fastly-Key", c.token)
req.Header.Set("Accept", "application/json")
resp, err := client.Do(req)
if err != nil {
return errors.Wrap(err, "error executing API services request")
return fmt.Errorf("error executing API services request: %w", err)
}
defer resp.Body.Close()

Expand All @@ -115,12 +114,12 @@ func (c *Cache) Refresh(client HTTPClient) error {
if response.Msg == "" {
response.Msg = "unknown error"
}
return errors.Errorf("api.fastly.com responded with %s (%s)", resp.Status, response.Msg)
return fmt.Errorf("api.fastly.com responded with %s (%s)", resp.Status, response.Msg)
}

var response []Service
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
return errors.Wrap(err, "error decoding API services response")
return fmt.Errorf("error decoding API services response: %w", err)
}

nextgen := map[string]Service{}
Expand Down Expand Up @@ -173,9 +172,7 @@ func (c *Cache) ServiceIDs() (ids []string) {
for _, s := range c.services {
ids = append(ids, s.ID)
}

sort.Strings(ids) // mostly for tests

return ids
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/rt/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"sort"
"sync"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/peterbourgon/fastly-exporter/pkg/gen"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/rt/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/google/go-cmp/cmp"
"github.com/peterbourgon/fastly-exporter/pkg/api"
"github.com/peterbourgon/fastly-exporter/pkg/filter"
Expand Down
7 changes: 3 additions & 4 deletions pkg/rt/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"strings"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
jsoniter "github.com/json-iterator/go"
"github.com/peterbourgon/fastly-exporter/pkg/gen"
"github.com/pkg/errors"
)

// HTTPClient is a consumer contract for the subscriber.
Expand Down Expand Up @@ -142,7 +141,7 @@ func (s *Subscriber) query(ctx context.Context, ts uint64) (currentName string,
u := fmt.Sprintf("https://rt.fastly.com/v1/channel/%s/ts/%d", url.QueryEscape(s.serviceID), ts)
req, err := http.NewRequest("GET", u, nil)
if err != nil {
return name, apiResultError, 0, ts, errors.Wrap(err, "error constructing real-time stats API request")
return name, apiResultError, 0, ts, fmt.Errorf("error constructing real-time stats API request: %w", err)
}

req.Header.Set("User-Agent", s.userAgent)
Expand Down

0 comments on commit 0d554a3

Please sign in to comment.