mirror of
https://github.com/openfaas/faas.git
synced 2025-06-16 21:06:54 +00:00
Report async execution duration
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
377520120c
commit
ec60d97518
@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/openfaas/faas/gateway/metrics"
|
||||
"github.com/openfaas/faas/gateway/requests"
|
||||
@ -22,5 +23,9 @@ func MakeAsyncReport(metrics metrics.MetricOptions) http.HandlerFunc {
|
||||
json.Unmarshal(bytesOut, &report)
|
||||
|
||||
trackInvocation(report.FunctionName, metrics, report.StatusCode)
|
||||
|
||||
var taken time.Duration
|
||||
taken = time.Duration(report.TimeTaken)
|
||||
trackTimeExact(taken, metrics, report.FunctionName)
|
||||
}
|
||||
}
|
||||
|
@ -220,3 +220,7 @@ func trackTime(then time.Time, metrics metrics.MetricOptions, name string) {
|
||||
since := time.Since(then)
|
||||
metrics.GatewayFunctionsHistogram.WithLabelValues(name).Observe(since.Seconds())
|
||||
}
|
||||
|
||||
func trackTimeExact(duration time.Duration, metrics metrics.MetricOptions, name string) {
|
||||
metrics.GatewayFunctionsHistogram.WithLabelValues(name).Observe(float64(duration))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user