Merge pull request #1 from yuki-tsuchiya/feature/handling_http_client_error
Fix handling http client error
This commit is contained in:
commit
bcc930b731
@ -7,7 +7,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
prom "github.com/prometheus/client_model/go"
|
prom "github.com/prometheus/client_model/go"
|
||||||
"github.com/prometheus/common/expfmt"
|
"github.com/prometheus/common/expfmt"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
@ -24,13 +23,15 @@ func (m *merger) merge(ctx context.Context, w io.Writer) error {
|
|||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
resp, err := m.client.Get(source.url)
|
resp, err := m.client.Get(source.url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, fmt.Sprintf("get url: %s", source.url))
|
fmt.Printf("get url: %s", source.url)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
tp := new(expfmt.TextParser)
|
tp := new(expfmt.TextParser)
|
||||||
out, err := tp.TextToMetricFamilies(resp.Body)
|
out, err := tp.TextToMetricFamilies(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, fmt.Sprintf("parse url: %s", source.url))
|
fmt.Printf("parse url: %s", source.url)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user