couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject git commit: Update to use couch_stats
Date Thu, 21 Aug 2014 06:57:11 GMT
Repository: couchdb-global-changes
Updated Branches:
  refs/heads/windsor-merge 8995b7062 -> 727868f16


Update to use couch_stats


Project: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/commit/727868f1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/tree/727868f1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/diff/727868f1

Branch: refs/heads/windsor-merge
Commit: 727868f16487e40c5b2281939cbe7beb7d764c1d
Parents: 8995b70
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Aug 21 01:56:48 2014 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Thu Aug 21 01:56:48 2014 -0500

----------------------------------------------------------------------
 priv/stats_descriptions.cfg     | 20 ++++++++++++++++++++
 src/global_changes.app.src      |  1 +
 src/global_changes_listener.erl |  9 +++++++++
 src/global_changes_server.erl   | 20 ++++++++++++++++++--
 4 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/727868f1/priv/stats_descriptions.cfg
----------------------------------------------------------------------
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
new file mode 100644
index 0000000..beb5248
--- /dev/null
+++ b/priv/stats_descriptions.cfg
@@ -0,0 +1,20 @@
+{[global_changes, db_writes], [
+    {type, counter},
+    {desc, <<"number of db writes performed by global changes">>}
+]}.
+{[global_changes, event_doc_conflict], [
+    {type, counter},
+    {desc, <<"number of conflicted event docs encountered by global changes">>}
+]}.
+{[global_changes, listener_pending_updates], [
+    {type, gauge},
+    {desc, <<"number of global changes updates pending writes in global_changes_listener">>}
+]}.
+{[global_changes, rpcs], [
+    {type, counter},
+    {desc, <<"number of rpc operations performed by global_changes">>}
+]}.
+{[global_changes, server_pending_updates], [
+    {type, gauge},
+    {desc, <<"number of global changes updates pending writes in global_changes_server">>}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/727868f1/src/global_changes.app.src
----------------------------------------------------------------------
diff --git a/src/global_changes.app.src b/src/global_changes.app.src
index ce34a80..4fb9a92 100644
--- a/src/global_changes.app.src
+++ b/src/global_changes.app.src
@@ -19,6 +19,7 @@
         stdlib,
         config,
         couch_log,
+        couch_stats,
         couch,
         mem3,
         fabric

http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/727868f1/src/global_changes_listener.erl
----------------------------------------------------------------------
diff --git a/src/global_changes_listener.erl b/src/global_changes_listener.erl
index 9befdfd..87a0268 100644
--- a/src/global_changes_listener.erl
+++ b/src/global_changes_listener.erl
@@ -80,6 +80,10 @@ handle_event(ShardName, Event, State0)
             EventBin = erlang:atom_to_binary(Event, latin1),
             Key = <<EventBin/binary, <<":">>/binary, DbName/binary>>,
             Pending = sets:add_element(Key, State0#state.pending_updates),
+            couch_stats:update_gauge(
+                [global_changes, listener_pending_updates],
+                Count + 1
+            ),
             State0#state{pending_updates=Pending, pending_update_count=Count+1}
     end,
     maybe_send_updates(State);
@@ -122,11 +126,16 @@ maybe_send_updates(#state{update_db=true}=State) ->
             try group_updates_by_node(State#state.dbname, Updates) of
                 Grouped ->
                     dict:map(fun(Node, Docs) ->
+                        couch_stats:increment_counter([global_changes, rpcs]),
                         global_changes_server:update_docs(Node, Docs)
                     end, Grouped)
             catch error:database_does_not_exist ->
                 ok
             end,
+            couch_stats:update_gauge(
+                [global_changes, listener_pending_updates],
+                0
+            ),
             State1 = State#state{
                 pending_updates=sets:new(),
                 pending_update_count=0,

http://git-wip-us.apache.org/repos/asf/couchdb-global-changes/blob/727868f1/src/global_changes_server.erl
----------------------------------------------------------------------
diff --git a/src/global_changes_server.erl b/src/global_changes_server.erl
index 5312459..812d6da 100644
--- a/src/global_changes_server.erl
+++ b/src/global_changes_server.erl
@@ -87,9 +87,14 @@ handle_cast(_Msg, #state{update_db=false}=State) ->
     {noreply, State};
 handle_cast({update_docs, DocIds}, State) ->
     Pending = sets:union(sets:from_list(DocIds), State#state.pending_updates),
+    PendingCount = sets:size(Pending),
+    couch_stats:update_gauge(
+        [global_changes, server_pending_updates],
+        PendingCount
+    ),
     NewState = State#state{
         pending_updates=Pending,
-        pending_update_count=sets:size(Pending)
+        pending_update_count=PendingCount
     },
     {noreply, NewState};
 
@@ -157,10 +162,20 @@ flush_updates(State) ->
 
         spawn(fun() ->
             fabric:update_docs(State#state.dbname, Docs, [])
-        end)
+        end),
+
+        Count = State#state.pending_update_count,
+        couch_stats:increment_counter(
+            [global_changes, db_writes],
+            Count
+        )
     catch error:database_does_not_exist ->
         {noreply, State}
     end,
+    couch_stats:update_gauge(
+        [global_changes, server_pending_updates],
+        0
+    ),
     {noreply, State#state{
         pending_updates=sets:new(),
         pending_update_count=0
@@ -203,5 +218,6 @@ get_rev({ok, #doc_info{revs=[RevInfo|_]}}) ->
     % global_changes should never encounter a conflict by design
     % but we should record if it happens in case our design isn't
     % quite right.
+    couch_stats:increment_counter([global_changes, event_doc_conflict]),
     {Pos, Rev} = RevInfo#rev_info.rev,
     {Pos, [Rev]}.


Mime
View raw message