mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-18 03:56:35 +00:00
Fix issue with provider metrics
https://github.com/openfaas/faas-provider/pull/66 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
11
vendor/github.com/openfaas/faas-provider/httputil/write_interceptor.go
generated
vendored
11
vendor/github.com/openfaas/faas-provider/httputil/write_interceptor.go
generated
vendored
@ -12,14 +12,14 @@ func NewHttpWriteInterceptor(w http.ResponseWriter) *HttpWriteInterceptor {
|
||||
|
||||
type HttpWriteInterceptor struct {
|
||||
http.ResponseWriter
|
||||
StatusCode int
|
||||
statusCode int
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Status() int {
|
||||
if c.StatusCode == 0 {
|
||||
if c.statusCode == 0 {
|
||||
return http.StatusOK
|
||||
}
|
||||
return c.StatusCode
|
||||
return c.statusCode
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Header() http.Header {
|
||||
@ -27,11 +27,14 @@ func (c *HttpWriteInterceptor) Header() http.Header {
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) Write(data []byte) (int, error) {
|
||||
if c.statusCode == 0 {
|
||||
c.WriteHeader(http.StatusOK)
|
||||
}
|
||||
return c.ResponseWriter.Write(data)
|
||||
}
|
||||
|
||||
func (c *HttpWriteInterceptor) WriteHeader(code int) {
|
||||
c.StatusCode = code
|
||||
c.statusCode = code
|
||||
c.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
|
||||
|
4
vendor/github.com/openfaas/faas-provider/metrics.go
generated
vendored
4
vendor/github.com/openfaas/faas-provider/metrics.go
generated
vendored
@ -53,7 +53,7 @@ func (hm *httpMetrics) InstrumentHandler(next http.Handler, pathOverride string)
|
||||
|
||||
defer func() {
|
||||
hm.RequestsTotal.With(
|
||||
prometheus.Labels{"code": strconv.Itoa(ww.StatusCode),
|
||||
prometheus.Labels{"code": strconv.Itoa(ww.Status()),
|
||||
"method": r.Method,
|
||||
"path": path,
|
||||
}).
|
||||
@ -62,7 +62,7 @@ func (hm *httpMetrics) InstrumentHandler(next http.Handler, pathOverride string)
|
||||
|
||||
defer func() {
|
||||
hm.RequestDurationHistogram.With(
|
||||
prometheus.Labels{"code": strconv.Itoa(ww.StatusCode),
|
||||
prometheus.Labels{"code": strconv.Itoa(ww.Status()),
|
||||
"method": r.Method,
|
||||
"path": path,
|
||||
}).
|
||||
|
Reference in New Issue
Block a user