mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 20:16:37 +00:00
Update comments
- updates comments and adds where missing - updates locks so that unlock is done via defer instead of at the end of the statement - extracts timeout variable in two places - remove makeClient() unused method from metrics package No-harm changes tested via go build. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
@ -13,16 +13,10 @@ import (
|
||||
"github.com/openfaas/faas/gateway/requests"
|
||||
)
|
||||
|
||||
func makeClient() http.Client {
|
||||
// Fine-tune the client to fail fast.
|
||||
return http.Client{}
|
||||
}
|
||||
|
||||
// AddMetricsHandler wraps a http.HandlerFunc with Prometheus metrics
|
||||
func AddMetricsHandler(handler http.HandlerFunc, prometheusQuery PrometheusQueryFetcher) http.HandlerFunc {
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// log.Printf("Calling upstream for function info\n")
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, r)
|
||||
@ -56,7 +50,6 @@ func AddMetricsHandler(handler http.HandlerFunc, prometheusQuery PrometheusQuery
|
||||
return
|
||||
}
|
||||
|
||||
// log.Printf("Querying Prometheus API\n")
|
||||
expr := url.QueryEscape(`sum(gateway_function_invocation_total{function_name=~".*", code=~".*"}) by (function_name, code)`)
|
||||
// expr := "sum(gateway_function_invocation_total%7Bfunction_name%3D~%22.*%22%2C+code%3D~%22.*%22%7D)+by+(function_name%2C+code)"
|
||||
results, fetchErr := prometheusQuery.Fetch(expr)
|
||||
@ -76,7 +69,6 @@ func AddMetricsHandler(handler http.HandlerFunc, prometheusQuery PrometheusQuery
|
||||
return
|
||||
}
|
||||
|
||||
// log.Printf("Writing bytesOut: %s\n", bytesOut)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write(bytesOut)
|
||||
|
Reference in New Issue
Block a user