From d6e5f0a154ce0e0563c4b86ead82be8bea40bc2a Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 15 Aug 2016 16:25:12 +0100 Subject: [PATCH] allow more accurate reporting of memcache hit ratio A lot of time could pass between recording the request count and hit count pertaining to a particular report fetching batch, which skewed calculations cache hit ratios. Fix that by defering the request count recording to the end, which is when we record the hit count. --- app/multitenant/memcache_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/multitenant/memcache_client.go b/app/multitenant/memcache_client.go index 6752d38d3..0a42b9953 100644 --- a/app/multitenant/memcache_client.go +++ b/app/multitenant/memcache_client.go @@ -150,7 +150,7 @@ func memcacheStatusCode(err error) string { // FetchReports gets reports from memcache. func (c *MemcacheClient) FetchReports(keys []string) (map[string]report.Report, []string, error) { - memcacheRequests.Add(float64(len(keys))) + defer memcacheRequests.Add(float64(len(keys))) var found map[string]*memcache.Item err := instrument.TimeRequestHistogramStatus("Get", memcacheRequestDuration, memcacheStatusCode, func() error { var err error