Report async execution duration

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis 2017-10-25 19:30:30 +01:00
parent 377520120c
commit ec60d97518
2 changed files with 9 additions and 0 deletions

View File

@ -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)
}
}

View File

@ -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))
}