fn: latency metrics for various call states (#1332)

* fn: latency metrics for various call states

This complements the API latency metrics available
on LB agent. In this case, we would like to measure
calls that have finished with the following status:
     "completed"
     "canceled"
     "timeouts"
     "errors"
     "server_busy"
and while measuring this latency, we subtract the
amount of time actual function execution took. This
is not precise, but an approximation mostly suitable
for trending.

Going forward, we could also subtract UDS wait time and/or
docker pull latency from this latency as an enhancement
to this PR.
This commit is contained in:
Tolga Ceylan
2018-11-30 13:20:59 -08:00
committed by GitHub
parent 88ba9e6215
commit df53250958
8 changed files with 116 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import (
"crypto/tls"
"io"
"net/http"
"time"
"github.com/fnproject/fn/api/common"
"github.com/fnproject/fn/api/models"
@@ -61,4 +62,7 @@ type RunnerCall interface {
ResponseWriter() http.ResponseWriter
StdErr() io.ReadWriteCloser
Model() *models.Call
// For metrics/stats, add special accounting for time spent in customer code
AddUserExecutionTime(dur time.Duration)
GetUserExecutionTime() *time.Duration
}