couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [18/22] couch commit: updated refs/heads/2491-refactor-couch-httpd-auth to 3e8286d
Date Thu, 04 Dec 2014 20:09:49 GMT
Track the time spent executing validate_doc_update functions


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/be6ddf24
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/be6ddf24
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/be6ddf24

Branch: refs/heads/2491-refactor-couch-httpd-auth
Commit: be6ddf24f62550bddd1dced0903bb508188b210e
Parents: 3e32256
Author: Alexander Shorin <kxepal@apache.org>
Authored: Fri Oct 31 00:40:09 2014 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Mon Nov 3 12:19:59 2014 +0300

----------------------------------------------------------------------
 priv/stats_descriptions.cfg |  4 ++++
 src/couch_db.erl            | 29 +++++++++++++++++------------
 2 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/be6ddf24/priv/stats_descriptions.cfg
----------------------------------------------------------------------
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
index 3f771d2..729fca1 100644
--- a/priv/stats_descriptions.cfg
+++ b/priv/stats_descriptions.cfg
@@ -186,3 +186,7 @@
     {type, counter},
     {desc, <<"number of rejections by validate_doc_update function">>}
 ]}.
+{[couchdb, query_server, vdu_process_time], [
+    {type, histogram},
+    {desc, <<"duration of validate_doc_update function calls">>}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/be6ddf24/src/couch_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_db.erl b/src/couch_db.erl
index b5ea64d..86b6558 100644
--- a/src/couch_db.erl
+++ b/src/couch_db.erl
@@ -582,18 +582,23 @@ validate_ddoc(DbName, DDoc) ->
     end.
 
 validate_doc_update_int(Db, Doc, GetDiskDocFun) ->
-    DiskDoc = GetDiskDocFun(),
-    JsonCtx = couch_util:json_user_ctx(Db),
-    SecObj = get_security(Db),
-    try [case Fun(Doc, DiskDoc, JsonCtx, SecObj) of
-            ok -> ok;
-            Error -> throw(Error)
-        end || Fun <- Db#db.validate_doc_funs],
-        ok
-    catch
-        throw:Error ->
-            Error
-    end.
+    Fun = fun() ->
+        DiskDoc = GetDiskDocFun(),
+        JsonCtx = couch_util:json_user_ctx(Db),
+        SecObj = get_security(Db),
+        try
+            [case Fun(Doc, DiskDoc, JsonCtx, SecObj) of
+                ok -> ok;
+                Error -> throw(Error)
+             end || Fun <- Db#db.validate_doc_funs],
+            ok
+        catch
+            throw:Error ->
+                Error
+        end
+    end,
+    couch_stats:update_histogram([couchdb, query_server, vdu_process_time],
+                                 Fun).
 
 
 % to be safe, spawn a middleman here


Mime
View raw message