admin/info: Add HTTPStats value as part of serverInfo() struct. (#4049)

Remove our counter implementation instead use atomic external
package which supports more types and methods.
This commit is contained in:
Harshavardhana
2017-04-06 23:08:33 -07:00
committed by GitHub
parent 1d99a560e3
commit 27749c2124
13 changed files with 771 additions and 131 deletions

View File

@@ -401,9 +401,21 @@ func (h httpStatsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Wraps w to record http response information
ww := &httpResponseRecorder{ResponseWriter: w}
// Time start before the call is about to start.
tBefore := UTCNow()
// Execute the request
h.handler.ServeHTTP(ww, r)
// Time after call has completed.
tAfter := UTCNow()
// Time duration in secs since the call started.
//
// We don't need to do nanosecond precision in this
// simply for the fact that it is not human readable.
durationSecs := tAfter.Sub(tBefore).Seconds()
// Update http statistics
globalHTTPStats.updateStats(r, ww)
globalHTTPStats.updateStats(r, ww, durationSecs)
}