Skip to content

Commit 311eae3

Browse files
committed
staticcheck fixes
1 parent b7e53bc commit 311eae3

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ format: ## Format the source code
1515
@find ./ -type f -name "*.go" -exec gofmt -w {} \;
1616

1717
lint: ## Lint the files
18-
@staticcheck
18+
@staticcheck -tests=false ${PKG_LIST}
1919

2020
vet: ## Vet the files
2121
@go vet ${PKG_LIST}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ require (
1818
github.com/uber/jaeger-client-go v2.25.0+incompatible
1919
github.com/uber/jaeger-lib v2.4.0+incompatible // indirect
2020
)
21-

jaegertracing/jaegertracing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TraceWithConfig(config TraceConfig) echo.MiddlewareFunc {
193193

194194
// Dump response body
195195
if config.IsBodyDump {
196-
sp.SetTag("http.resp.body", string(resBody.Bytes()))
196+
sp.SetTag("http.resp.body", resBody.String())
197197
}
198198

199199
sp.Finish()

prometheus/prometheus.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ type Prometheus struct {
133133
// PushGateway contains the configuration for pushing to a Prometheus pushgateway (optional)
134134
type 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

246245
func (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)

zipkintracing/response_writer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,6 @@ func (rw *responseWriter) Flush() {
101101
}
102102

103103
func (rw *responseWriter) CloseNotify() <-chan bool {
104+
//lint:ignore SA1019 we support it for backwards compatibility reasons
104105
return rw.ResponseWriter.(http.CloseNotifier).CloseNotify()
105106
}

0 commit comments

Comments
 (0)