summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-03-14 14:56:35 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-03-14 14:56:35 -0400
commit7a7b293113b86cfb007ea92dab4eafa7024bd6da (patch)
treeb5caa853cf590e31620137ba1de92aa2651816d5 /api
parentdc2e73305858bad53a9f1d1cba407649890d2497 (diff)
downloadchat-7a7b293113b86cfb007ea92dab4eafa7024bd6da.tar.gz
chat-7a7b293113b86cfb007ea92dab4eafa7024bd6da.tar.bz2
chat-7a7b293113b86cfb007ea92dab4eafa7024bd6da.zip
Moving HTTP request counter to the start of ServeHTTP so count time is not effected by request duration. (#5764)
Diffstat (limited to 'api')
-rw-r--r--api/context.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/api/context.go b/api/context.go
index 21989f775..9a707c968 100644
--- a/api/context.go
+++ b/api/context.go
@@ -102,6 +102,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
now := time.Now()
l4g.Debug("%v", r.URL.Path)
+ if metrics := einterfaces.GetMetricsInterface(); metrics != nil && h.isApi {
+ metrics.IncrementHttpRequest()
+ }
+
c := &Context{}
c.T, c.Locale = utils.GetTranslationsAndLocale(w, r)
c.RequestId = model.NewId()
@@ -250,8 +254,6 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if h.isApi && einterfaces.GetMetricsInterface() != nil {
- einterfaces.GetMetricsInterface().IncrementHttpRequest()
-
if r.URL.Path != model.API_URL_SUFFIX_V3+"/users/websocket" {
elapsed := float64(time.Since(now)) / float64(time.Second)
einterfaces.GetMetricsInterface().ObserveHttpRequestDuration(elapsed)