From f96173528f08684092b89f903f0389fe2b607192 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 19 Dec 2016 10:16:22 -0500 Subject: Adding metrics for caching mechanisms (#4828) --- store/sql_post_store.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'store/sql_post_store.go') diff --git a/store/sql_post_store.go b/store/sql_post_store.go index 44ae58b32..befb38b6a 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" + "github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" ) @@ -227,16 +228,28 @@ func (s SqlPostStore) InvalidatePostEtagCache(channelId string) { func (s SqlPostStore) GetEtag(channelId string, allowFromCache bool) StoreChannel { storeChannel := make(StoreChannel, 1) + metrics := einterfaces.GetMetricsInterface() go func() { result := StoreResult{} if allowFromCache { if cacheItem, ok := postEtagCache.Get(channelId); ok { + if metrics != nil { + metrics.IncrementMemCacheHitCounter("Post Etag") + } result.Data = cacheItem.(string) storeChannel <- result close(storeChannel) return + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("Post Etag") + } + } + } else { + if metrics != nil { + metrics.IncrementMemCacheMissCounter("Post Etag") } } -- cgit v1.2.3-1-g7c22