summaryrefslogtreecommitdiffstats
path: root/api/api.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-12-19 10:16:22 -0500
committerGitHub <noreply@github.com>2016-12-19 10:16:22 -0500
commitf96173528f08684092b89f903f0389fe2b607192 (patch)
treef34f9057417ad6758cd65dc246bc764530f2134c /api/api.go
parent6a5cdd5cdf09317ce259dd146fc4f1cb76d8b9b6 (diff)
downloadchat-f96173528f08684092b89f903f0389fe2b607192.tar.gz
chat-f96173528f08684092b89f903f0389fe2b607192.tar.bz2
chat-f96173528f08684092b89f903f0389fe2b607192.zip
Adding metrics for caching mechanisms (#4828)
Diffstat (limited to 'api/api.go')
-rw-r--r--api/api.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/api/api.go b/api/api.go
index 926edfe34..122a6b933 100644
--- a/api/api.go
+++ b/api/api.go
@@ -7,6 +7,7 @@ import (
"net/http"
"github.com/gorilla/mux"
+ "github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
@@ -114,15 +115,23 @@ func InitApi() {
InitEmailBatching()
}
-func HandleEtag(etag string, w http.ResponseWriter, r *http.Request) bool {
+func HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool {
+ metrics := einterfaces.GetMetricsInterface()
if et := r.Header.Get(model.HEADER_ETAG_CLIENT); len(etag) > 0 {
if et == etag {
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
w.WriteHeader(http.StatusNotModified)
+ if metrics != nil {
+ metrics.IncrementEtagHitCounter(routeName)
+ }
return true
}
}
+ if metrics != nil {
+ metrics.IncrementEtagMissCounter(routeName)
+ }
+
return false
}