Skip to content

Commit

Permalink
Incorporate review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vjsamuel committed Aug 26, 2020
1 parent 4f2897c commit 5321417
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions metricbeat/helper/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewPrometheusClient(base mb.BaseMetricSet) (Prometheus, error) {
}

http.SetHeaderDefault("Accept", acceptHeader)
http.SetHeader("Accept-Encoding", "gzip")
http.SetHeaderDefault("Accept-Encoding", "gzip")
return &prometheus{http, base.Logger()}, nil
}

Expand All @@ -79,10 +79,12 @@ func (p *prometheus) GetFamilies() ([]*dto.MetricFamily, error) {
defer resp.Body.Close()

if resp.Header.Get("Content-Encoding") == "gzip" {
reader, err = gzip.NewReader(resp.Body)
greader, err := gzip.NewReader(resp.Body)
if err != nil {
return nil, err
}
defer greader.Close()
reader = greader
} else {
reader = resp.Body
}
Expand Down

0 comments on commit 5321417

Please sign in to comment.