mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 03:56:37 +00:00
Record metrics for invocations when they start
* This experimental patch records metrics as invocations start so that the metrics can be used to make better scale to zero decisions in faas-idler. Tested with Kubernetes on a single-node cluster, metrics reported as expected. Existing metrics still report. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
1eea381dd5
commit
96812d2cd8
@ -53,9 +53,12 @@ func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy,
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
baseURL := baseURLResolver.Resolve(r)
|
||||
originalURL := r.URL.String()
|
||||
|
||||
requestURL := urlPathTransformer.Transform(r)
|
||||
|
||||
for _, notifier := range notifiers {
|
||||
notifier.Notify(r.Method, requestURL, originalURL, http.StatusProcessing, "started", time.Second*0)
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
statusCode, err := forwardRequest(w, r, proxy.Client, baseURL, requestURL, proxy.Timeout, writeRequestURI, serviceAuthInjector)
|
||||
@ -66,7 +69,7 @@ func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy,
|
||||
}
|
||||
|
||||
for _, notifier := range notifiers {
|
||||
notifier.Notify(r.Method, requestURL, originalURL, statusCode, seconds)
|
||||
notifier.Notify(r.Method, requestURL, originalURL, statusCode, "completed", seconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user