Moving HTTP request counter to the start of ServeHTTP so count time is not effected by request duration. (#5764)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
dc2e733058
Коммит
7a7b293113
@@ -102,6 +102,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
now := time.Now()
|
now := time.Now()
|
||||||
l4g.Debug("%v", r.URL.Path)
|
l4g.Debug("%v", r.URL.Path)
|
||||||
|
|
||||||
|
if metrics := einterfaces.GetMetricsInterface(); metrics != nil && h.isApi {
|
||||||
|
metrics.IncrementHttpRequest()
|
||||||
|
}
|
||||||
|
|
||||||
c := &Context{}
|
c := &Context{}
|
||||||
c.T, c.Locale = utils.GetTranslationsAndLocale(w, r)
|
c.T, c.Locale = utils.GetTranslationsAndLocale(w, r)
|
||||||
c.RequestId = model.NewId()
|
c.RequestId = model.NewId()
|
||||||
@@ -250,8 +254,6 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if h.isApi && einterfaces.GetMetricsInterface() != nil {
|
if h.isApi && einterfaces.GetMetricsInterface() != nil {
|
||||||
einterfaces.GetMetricsInterface().IncrementHttpRequest()
|
|
||||||
|
|
||||||
if r.URL.Path != model.API_URL_SUFFIX_V3+"/users/websocket" {
|
if r.URL.Path != model.API_URL_SUFFIX_V3+"/users/websocket" {
|
||||||
elapsed := float64(time.Since(now)) / float64(time.Second)
|
elapsed := float64(time.Since(now)) / float64(time.Second)
|
||||||
einterfaces.GetMetricsInterface().ObserveHttpRequestDuration(elapsed)
|
einterfaces.GetMetricsInterface().ObserveHttpRequestDuration(elapsed)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user