Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Pivotto <roidelapluie@gmail.com>
Signed-off-by: Thomas de Grenier de Latour <thomas.degrenierdelatour@orange.com>
  • Loading branch information
thomasgl-orange and roidelapluie committed May 3, 2022
1 parent 43f230b commit bfcaa67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ haproxy_exporter --no-haproxy.ssl-verify --haproxy.scrape-uri="https://haproxy.e
```

If scraping a remote HAProxy must be done via an HTTP proxy, you can enable reading of the
standard `$HTTP_PROXY` / `$HTTPS_PROXY` / `$NO_PROXY` environment variables by using the
standard [`$http_proxy` / `$https_proxy` / `$no_proxy` environment variables](https://pkg.go.dev/net/http#ProxyFromEnvironment) by using the
`--http.proxy-from-env` flag (these variables will be ignored otherwise):

```bash
Expand Down
6 changes: 3 additions & 3 deletions haproxy_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ type Exporter struct {
}

// NewExporter returns an initialized Exporter.
func NewExporter(uri string, sslVerify bool, proxyFromEnv bool, selectedServerMetrics map[int]metricInfo, excludedServerStates string, timeout time.Duration, logger log.Logger) (*Exporter, error) {
func NewExporter(uri string, sslVerify, proxyFromEnv bool, selectedServerMetrics map[int]metricInfo, excludedServerStates string, timeout time.Duration, logger log.Logger) (*Exporter, error) {
u, err := url.Parse(uri)
if err != nil {
return nil, err
Expand Down Expand Up @@ -331,7 +331,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
ch <- e.csvParseFailures
}

func fetchHTTP(uri string, sslVerify bool, proxyFromEnv bool, timeout time.Duration) func() (io.ReadCloser, error) {
func fetchHTTP(uri string, sslVerify, proxyFromEnv bool, timeout time.Duration) func() (io.ReadCloser, error) {
tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: !sslVerify}}
if proxyFromEnv {
tr.Proxy = http.ProxyFromEnvironment
Expand Down Expand Up @@ -569,7 +569,7 @@ func main() {
haProxyServerExcludeStates = kingpin.Flag("haproxy.server-exclude-states", "Comma-separated list of exported server states to exclude. See https://cbonte.github.io/haproxy-dconv/1.8/management.html#9.1, field 17 statuus").Default(excludedServerStates).String()
haProxyTimeout = kingpin.Flag("haproxy.timeout", "Timeout for trying to get stats from HAProxy.").Default("5s").Duration()
haProxyPidFile = kingpin.Flag("haproxy.pid-file", pidFileHelpText).Default("").String()
httpProxyFromEnv = kingpin.Flag("http.proxy-from-env", "Flag that enables using HTTP proxy settings from environment variables ($HTTP_PROXY, $HTTPS_PROXY, $NO_PROXY)").Default("false").Bool()
httpProxyFromEnv = kingpin.Flag("http.proxy-from-env", "Flag that enables using HTTP proxy settings from environment variables ($http_proxy, $https_proxy, $no_proxy)").Default("false").Bool()
)

promlogConfig := &promlog.Config{}
Expand Down

0 comments on commit bfcaa67

Please sign in to comment.