Update to use couch_stats windsor-merge
authorPaul J. Davis <paul.joseph.davis@gmail.com>
Thu, 21 Aug 2014 06:49:43 +0000 (01:49 -0500)
committerPaul J. Davis <paul.joseph.davis@gmail.com>
Thu, 21 Aug 2014 06:49:43 +0000 (01:49 -0500)
priv/stats_descriptions.cfg [new file with mode: 0644]
src/ddoc_cache.app.src
src/ddoc_cache.erl

diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
new file mode 100644 (file)
index 0000000..f769a97
--- /dev/null
@@ -0,0 +1,12 @@
+{[ddoc_cache, hit], [
+    {type, counter},
+    {desc, <<"number of design doc cache hits">>}
+]}.
+{[ddoc_cache, miss], [
+    {type, counter},
+    {desc, <<"number of design doc cache misses">>}
+]}.
+{[ddoc_cache, recovery], [
+    {type, counter},
+    {desc, <<"number of design doc cache recoveries">>}
+]}.
index 7d03bdf..a64b2f5 100644 (file)
@@ -32,7 +32,8 @@
         ets_lru,
         mem3,
         fabric,
-        couch_log
+        couch_log,
+        couch_stats
     ]},
     {mod, {ddoc_cache_app, []}},
     {env, [
index 40d9467..6aa3efd 100644 (file)
@@ -37,10 +37,13 @@ open_doc(DbName, DocId) ->
     Key = {DbName, DocId, '_'},
     case ddoc_cache_opener:match_newest(Key) of
         {ok, _} = Resp ->
+            couch_stats:increment_counter([ddoc_cache, hit]),
             Resp;
         missing ->
+            couch_stats:increment_counter([ddoc_cache, miss]),
             ddoc_cache_opener:open_doc(DbName, DocId);
         recover ->
+            couch_stats:increment_counter([ddoc_cache, recovery]),
             ddoc_cache_opener:recover_doc(DbName, DocId)
     end.
 
@@ -48,10 +51,13 @@ open_doc(DbName, DocId, RevId) ->
     Key = {DbName, DocId, RevId},
     case ddoc_cache_opener:lookup(Key) of
         {ok, _} = Resp ->
+            couch_stats:increment_counter([ddoc_cache, hit]),
             Resp;
         missing ->
+            couch_stats:increment_counter([ddoc_cache, miss]),
             ddoc_cache_opener:open_doc(DbName, DocId, RevId);
         recover ->
+            couch_stats:increment_counter([ddoc_cache, recovery]),
             ddoc_cache_opener:recover_doc(DbName, DocId, RevId)
     end.
 
@@ -59,10 +65,13 @@ open_validation_funs(DbName) ->
     Key = {DbName, validation_funs},
     case ddoc_cache_opener:lookup(Key) of
         {ok, _} = Resp ->
+            couch_stats:increment_counter([ddoc_cache, hit]),
             Resp;
         missing ->
+            couch_stats:increment_counter([ddoc_cache, mis]),
             ddoc_cache_opener:open_validation_funs(DbName);
         recover ->
+            couch_stats:increment_counter([ddoc_cache, recovery]),
             ddoc_cache_opener:recover_validation_funs(DbName)
     end.