chore: fix linting problems

This commit is contained in:
Daniel Thomas 2021-11-16 15:12:50 +01:00
parent 0668e3a09c
commit 13d94e64ed
2 changed files with 9 additions and 7 deletions

4
go.mod
View File

@ -4,6 +4,8 @@ go 1.17
require (
github.com/foomo/keel v0.3.1
github.com/prometheus/client_golang v1.10.0
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.7.0
go.uber.org/zap v1.19.1
)
@ -27,7 +29,6 @@ require (
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.10.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.18.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
@ -36,7 +37,6 @@ require (
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/spf13/viper v1.7.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
go.opentelemetry.io/contrib v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/host v0.20.0 // indirect

View File

@ -3,9 +3,10 @@ package proxy
import (
"context"
"encoding/json"
"github.com/foomo/contentfulproxy/packages/go/metrics"
"net/http"
"github.com/foomo/contentfulproxy/packages/go/metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/foomo/contentfulproxy/packages/go/log"
@ -21,7 +22,7 @@ type Info struct {
type Metrics struct {
NumUpdate prometheus.Counter
NumProxyRequest prometheus.Counter
NumApiRequest prometheus.Counter
NumAPIRequest prometheus.Counter
}
type Proxy struct {
@ -71,7 +72,7 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
cachedResponse = jobDone.cachedResponse
p.l.Info("serve response after cache creation", log.FURL(r.RequestURI), log.FCacheID(string(cacheID)))
p.metrics.NumApiRequest.Inc()
p.metrics.NumAPIRequest.Inc()
} else {
p.l.Info("serve response from cache", log.FURL(r.RequestURI), log.FCacheID(string(cacheID)))
}
@ -156,10 +157,11 @@ func jsonResponse(w http.ResponseWriter, v interface{}, statusCode int) {
http.Error(w, "could not marshal info export", http.StatusInternalServerError)
}
}
func getMetrics() *Metrics {
return &Metrics{
NumUpdate: metrics.NewCounter("numupdates", "number of times the update webhook was called"),
NumApiRequest: metrics.NewCounter("numapirequests", "number of times the proxy performed a contentful api-request"),
NumUpdate: metrics.NewCounter("numupdates", "number of times the update webhook was called"),
NumAPIRequest: metrics.NewCounter("numapirequests", "number of times the proxy performed a contentful api-request"),
NumProxyRequest: metrics.NewCounter("numproxyrequests", "number of times the proxy received an api-request"),
}
}