Skip to content

Commit

Permalink
Merge pull request #172 from prometheus-community/superq/errors_pkg
Browse files Browse the repository at this point in the history
Cleanup obsolete package use
  • Loading branch information
SuperQ authored Mar 29, 2024
2 parents c97812e + e173ea6 commit 6d34c4c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
13 changes: 6 additions & 7 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"io"
"net"
Expand All @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions cmd/client/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
package main

import (
"errors"
"fmt"
"net/http"
"net/http/httptest"
"testing"

"github.com/pkg/errors"
)

type TestLogger struct{}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 6d34c4c

Please sign in to comment.