Skip to content

Commit

Permalink
Merge branch 'master' of github.com:QubitProducts/exporter_exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurie Clark-Michalek committed Feb 2, 2017
2 parents 8937e86 + ec4c548 commit c80b52f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 11 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/http"
"time"

"github.com/golang/glog"
Expand Down Expand Up @@ -58,8 +59,9 @@ type httpConfig struct {
Address string `yaml:"address"` // 127.0.0.1
XXX map[string]interface{} `yaml:",inline"`

tlsConfig *tls.Config
mcfg *moduleConfig
tlsConfig *tls.Config
httpClient *http.Client
mcfg *moduleConfig
}

type execConfig struct {
Expand Down Expand Up @@ -136,11 +138,16 @@ func checkModuleConfig(name string, cfg *moduleConfig) error {
cfg.HTTP.Address = "localhost"
}

var err error
cfg.HTTP.tlsConfig, err = cfg.HTTP.getTLSConfig()
tlsConfig, err := cfg.HTTP.getTLSConfig()
if err != nil {
return errors.Wrap(err, "could not create tls config")
}
cfg.HTTP.tlsConfig = tlsConfig
cfg.HTTP.httpClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
}
case "exec":
if len(cfg.Exec.XXX) != 0 {
return fmt.Errorf("Unknown exec module configuration fields: %v", cfg.Exec.XXX)
Expand Down
7 changes: 1 addition & 6 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ func (c httpConfig) GatherWithContext(ctx context.Context, r *http.Request) prom
Path: c.Path,
RawQuery: vs.Encode(),
}
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: c.tlsConfig,
},
}
resp, err := ctxhttp.Get(ctx, client, url.String())
resp, err := ctxhttp.Get(ctx, c.httpClient, url.String())
if err != nil {
if glog.V(1) {
glog.Errorf("http proxy for module %v failed %+v", c.mcfg.name, err)
Expand Down

0 comments on commit c80b52f

Please sign in to comment.