@@ -133,6 +133,7 @@ type Prometheus struct {
133133// PushGateway contains the configuration for pushing to a Prometheus pushgateway (optional)
134134type PushGateway struct {
135135 // Push interval in seconds
136+ //lint:ignore ST1011 renaming would be breaking change
136137 PushIntervalSeconds time.Duration
137138
138139 // Push Gateway URL in format http://domain:port
@@ -156,9 +157,7 @@ func NewPrometheus(subsystem string, skipper middleware.Skipper, customMetricsLi
156157 metricsList = customMetricsList [0 ]
157158 }
158159
159- for _ , metric := range standardMetrics {
160- metricsList = append (metricsList , metric )
161- }
160+ metricsList = append (metricsList , standardMetrics ... )
162161
163162 p := & Prometheus {
164163 MetricsList : metricsList ,
@@ -179,10 +178,10 @@ func NewPrometheus(subsystem string, skipper middleware.Skipper, customMetricsLi
179178}
180179
181180// SetPushGateway sends metrics to a remote pushgateway exposed on pushGatewayURL
182- // every pushIntervalSeconds . Metrics are fetched from
183- func (p * Prometheus ) SetPushGateway (pushGatewayURL string , pushIntervalSeconds time.Duration ) {
181+ // every pushInterval . Metrics are fetched from
182+ func (p * Prometheus ) SetPushGateway (pushGatewayURL string , pushInterval time.Duration ) {
184183 p .Ppg .PushGatewayURL = pushGatewayURL
185- p .Ppg .PushIntervalSeconds = pushIntervalSeconds
184+ p .Ppg .PushIntervalSeconds = pushInterval
186185 p .startPushTicker ()
187186}
188187
@@ -245,6 +244,10 @@ func (p *Prometheus) getPushGatewayURL() string {
245244
246245func (p * Prometheus ) sendMetricsToPushGateway (metrics []byte ) {
247246 req , err := http .NewRequest ("POST" , p .getPushGatewayURL (), bytes .NewBuffer (metrics ))
247+ if err != nil {
248+ log .Errorf ("failed to create push gateway request: %v" , err )
249+ return
250+ }
248251 client := & http.Client {}
249252 if _ , err = client .Do (req ); err != nil {
250253 log .Errorf ("Error sending to push gateway: %v" , err )
0 commit comments