diff --git a/cmd/client/main.go b/cmd/client/main.go index 8fac5e3..6184182 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -19,6 +19,7 @@ import ( "context" "crypto/tls" "crypto/x509" + "errors" "fmt" "io" "net" @@ -33,7 +34,6 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/go-kit/log" "github.com/go-kit/log/level" - "github.com/pkg/errors" "github.com/prometheus-community/pushprox/util" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -134,8 +134,7 @@ func (c *Coordinator) doScrape(request *http.Request, client *http.Client) { scrapeResp, err := client.Do(request) if err != nil { - msg := fmt.Sprintf("failed to scrape %s", request.URL.String()) - c.handleErr(request, client, errors.Wrap(err, msg)) + c.handleErr(request, client, fmt.Errorf("failed to scrape %s: %w", request.URL.String(), err)) return } level.Info(logger).Log("msg", "Retrieved scrape response") @@ -184,25 +183,25 @@ func (c *Coordinator) doPoll(client *http.Client) error { base, err := url.Parse(*proxyURL) if err != nil { level.Error(c.logger).Log("msg", "Error parsing url:", "err", err) - return errors.Wrap(err, "error parsing url") + return fmt.Errorf("error parsing url: %w", err) } u, err := url.Parse("poll") if err != nil { level.Error(c.logger).Log("msg", "Error parsing url:", "err", err) - return errors.Wrap(err, "error parsing url poll") + return fmt.Errorf("error parsing url poll: %w", err) } url := base.ResolveReference(u) resp, err := client.Post(url.String(), "", strings.NewReader(*myFqdn)) if err != nil { level.Error(c.logger).Log("msg", "Error polling:", "err", err) - return errors.Wrap(err, "error polling") + return fmt.Errorf("error polling: %w", err) } defer resp.Body.Close() request, err := http.ReadRequest(bufio.NewReader(resp.Body)) if err != nil { level.Error(c.logger).Log("msg", "Error reading request:", "err", err) - return errors.Wrap(err, "error reading request") + return fmt.Errorf("error reading request: %w", err) } level.Info(c.logger).Log("msg", "Got scrape request", "scrape_id", request.Header.Get("id"), "url", request.URL) diff --git a/cmd/client/main_test.go b/cmd/client/main_test.go index 0adeec2..b7bc92c 100644 --- a/cmd/client/main_test.go +++ b/cmd/client/main_test.go @@ -14,12 +14,11 @@ package main import ( + "errors" "fmt" "net/http" "net/http/httptest" "testing" - - "github.com/pkg/errors" ) type TestLogger struct{} diff --git a/go.mod b/go.mod index f3dd873..6b6bc1c 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,6 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-kit/log v0.2.1 github.com/google/uuid v1.6.0 - github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.19.0 github.com/prometheus/common v0.51.1 ) diff --git a/go.sum b/go.sum index c414ce5..d739f19 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -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= github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=