diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-06-04 04:56:03 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-06-04 04:56:03 +0300 |
commit | c877296b468e4a828da27f4fd47c3e17eb7e2e1d (patch) | |
tree | 699bfd4507f8645b1f5b9a0dc2a717870a960c88 /app.go | |
parent | 4eedf5c25e17698d03cd71960040f155f51672c9 (diff) |
Add serving time metric for all files
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -7,6 +7,7 @@ import ( "net/http" "os" "sync" + "time" ghandlers "github.com/gorilla/handlers" "github.com/rs/cors" @@ -257,6 +258,9 @@ func (a *theApp) accessControlMiddleware(handler http.Handler) http.Handler { // return a 404 Not Found response func (a *theApp) serveFileOrNotFoundHandler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + defer metrics.ServingTime.Set(time.Since(start).Seconds()) + domain := request.GetDomain(r) fileServed := domain.ServeFileHTTP(w, r) |