couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [36/50] [abbrv] couch-replicator commit: updated refs/heads/1963-eunit-bigcouch to 3cf0b13
Date Thu, 28 Aug 2014 17:30:36 GMT
Update to use couch_stats


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

Branch: refs/heads/1963-eunit-bigcouch
Commit: aafb5f9d9b97d0cadb21b10e338cca6c9caf6afd
Parents: a85e9b8
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Aug 21 01:47:01 2014 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Thu Aug 21 01:47:01 2014 -0500

----------------------------------------------------------------------
 priv/stats_descriptions.cfg             | 56 ++++++++++++++++++++++++++++
 src/couch_replicator.app.src            |  3 +-
 src/couch_replicator.erl                | 10 +++++
 src/couch_replicator_changes_reader.erl |  3 ++
 src/couch_replicator_httpc.erl          |  9 +++++
 5 files changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/aafb5f9d/priv/stats_descriptions.cfg
----------------------------------------------------------------------
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
new file mode 100644
index 0000000..2564f92
--- /dev/null
+++ b/priv/stats_descriptions.cfg
@@ -0,0 +1,56 @@
+{[couch_replicator, changes_read_failures], [
+    {type, counter},
+    {desc, <<"number of failed replicator changes read failures">>}
+]}.
+{[couch_replicator, changes_reader_deaths], [
+    {type, counter},
+    {desc, <<"number of failed replicator changes readers">>}
+]}.
+{[couch_replicator, changes_manager_deaths], [
+    {type, counter},
+    {desc, <<"number of failed replicator changes managers">>}
+]}.
+{[couch_replicator, changes_queue_deaths], [
+    {type, counter},
+    {desc, <<"number of failed replicator changes work queues">>}
+]}.
+{[couch_replicator, checkpoints, success], [
+    {type, counter},
+    {desc, <<"number of checkpoints successfully saves">>}
+]}.
+{[couch_replicator, checkpoints, failure], [
+    {type, counter},
+    {desc, <<"number of failed checkpoint saves">>}
+]}.
+{[couch_replicator, failed_starts], [
+    {type, counter},
+    {desc, <<"number of replications that have failed to start">>}
+]}.
+{[couch_replicator, requests], [
+    {type, counter},
+    {desc, <<"number of HTTP requests made by the replicator">>}
+]}.
+{[couch_replicator, responses, failure], [
+    {type, counter},
+    {desc, <<"number of failed HTTP responses received by the replicator">>}
+]}.
+{[couch_replicator, responses, success], [
+    {type, counter},
+    {desc, <<"number of successful HTTP responses received by the replicator">>}
+]}.
+{[couch_replicator, stream_responses, failure], [
+    {type, counter},
+    {desc, <<"number of failed streaming HTTP responses received by the replicator">>}
+]}.
+{[couch_replicator, stream_responses, success], [
+    {type, counter},
+    {desc, <<"number of successful streaming HTTP responses received by the replicator">>}
+]}.
+{[couch_replicator, worker_deaths], [
+    {type, counter},
+    {desc, <<"number of failed replicator workers">>}
+]}.
+{[couch_replicator, workers_started], [
+    {type, counter},
+    {desc, <<"number of replicator workers started">>}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/aafb5f9d/src/couch_replicator.app.src
----------------------------------------------------------------------
diff --git a/src/couch_replicator.app.src b/src/couch_replicator.app.src
index f4470f2..4f12195 100644
--- a/src/couch_replicator.app.src
+++ b/src/couch_replicator.app.src
@@ -39,7 +39,8 @@
         couch_log,
         mem3,
         couch,
-        couch_event
+        couch_event,
+        couch_stats
     ]}
 ]}.
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/aafb5f9d/src/couch_replicator.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator.erl b/src/couch_replicator.erl
index 6bfd3bb..ee45d0b 100644
--- a/src/couch_replicator.erl
+++ b/src/couch_replicator.erl
@@ -265,6 +265,7 @@ do_init(#rep{options = Options, id = {BaseId, Ext}, user_ctx=UserCtx}
= Rep) ->
     MaxConns = get_value(http_connections, Options),
     Workers = lists:map(
         fun(_) ->
+            couch_stats:increment_counter([couch_replicator, workers_started]),
             {ok, Pid} = couch_replicator_worker:start_link(
                 self(), Source, Target, ChangesManager, MaxConns),
             Pid
@@ -347,6 +348,7 @@ handle_info({'EXIT', Pid, normal}, #rep_state{changes_reader=Pid} = State)
->
     {noreply, State};
 
 handle_info({'EXIT', Pid, Reason}, #rep_state{changes_reader=Pid} = State) ->
+    couch_stats:increment_counter([couch_replicator, changes_reader_deaths]),
     couch_log:error("ChangesReader process died with reason: ~p", [Reason]),
     {stop, changes_reader_died, cancel_timer(State)};
 
@@ -354,6 +356,7 @@ handle_info({'EXIT', Pid, normal}, #rep_state{changes_manager = Pid} =
State) ->
     {noreply, State};
 
 handle_info({'EXIT', Pid, Reason}, #rep_state{changes_manager = Pid} = State) ->
+    couch_stats:increment_counter([couch_replicator, changes_manager_deaths]),
     couch_log:error("ChangesManager process died with reason: ~p", [Reason]),
     {stop, changes_manager_died, cancel_timer(State)};
 
@@ -361,6 +364,7 @@ handle_info({'EXIT', Pid, normal}, #rep_state{changes_queue=Pid} = State)
->
     {noreply, State};
 
 handle_info({'EXIT', Pid, Reason}, #rep_state{changes_queue=Pid} = State) ->
+    couch_stats:increment_counter([couch_replicator, changes_queue_deaths]),
     couch_log:error("ChangesQueue process died with reason: ~p", [Reason]),
     {stop, changes_queue_died, cancel_timer(State)};
 
@@ -385,6 +389,7 @@ handle_info({'EXIT', Pid, Reason}, #rep_state{workers = Workers} = State)
->
     false ->
         {stop, {unknown_process_died, Pid, Reason}, State2};
     true ->
+        couch_stats:increment_counter([couch_replicator, worker_deaths]),
         couch_log:error("Worker ~p died with reason: ~p", [Pid, Reason]),
         {stop, {worker_died, Pid, Reason}, State2}
     end;
@@ -453,8 +458,10 @@ handle_cast({db_compacted, DbName},
 handle_cast(checkpoint, State) ->
     case do_checkpoint(State) of
     {ok, NewState} ->
+        couch_stats:increment_counter([couch_replicator, checkpoints, success]),
         {noreply, NewState#rep_state{timer = start_timer(State)}};
     Error ->
+        couch_stats:increment_counter([couch_replicator, checkpoints, failure]),
         {stop, Error, State}
     end;
 
@@ -493,6 +500,7 @@ terminate(Reason, #rep_state{} = State) ->
 
 terminate(shutdown, {error, Class, Error, Stack, InitArgs}) ->
     #rep{id=RepId} = InitArgs,
+    couch_stats:increment_counter([couch_replicator, failed_starts]),
     couch_log:error("~p:~p: Replication failed to start for args ~p: ~p",
              [Class, Error, InitArgs, Stack]),
     case Error of
@@ -521,8 +529,10 @@ do_last_checkpoint(#rep_state{seqs_in_progress = [],
     highest_seq_done = Seq} = State) ->
     case do_checkpoint(State#rep_state{current_through_seq = Seq}) of
     {ok, NewState} ->
+        couch_stats:increment_counter([couch_replicator, checkpoints, success]),
         {stop, normal, cancel_timer(NewState)};
     Error ->
+        couch_stats:increment_counter([couch_replicator, checkpoints, failure]),
         {stop, Error, State}
     end.
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/aafb5f9d/src/couch_replicator_changes_reader.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_changes_reader.erl b/src/couch_replicator_changes_reader.erl
index 623e8f9..b7d18e0 100644
--- a/src/couch_replicator_changes_reader.erl
+++ b/src/couch_replicator_changes_reader.erl
@@ -53,6 +53,9 @@ read_changes(Parent, StartSeq, Db, ChangesQueue, Options, Ts) ->
             LS = get(last_seq),
             read_changes(Parent, LS, Db, ChangesQueue, Options, Ts+1);
         exit:{http_request_failed, _, _, _} = Error ->
+        couch_stats:increment_counter(
+            [couch_replicator, changes_read_failures]
+        ),
         case get(retries_left) of
         N when N > 0 ->
             put(retries_left, N - 1),

http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/aafb5f9d/src/couch_replicator_httpc.erl
----------------------------------------------------------------------
diff --git a/src/couch_replicator_httpc.erl b/src/couch_replicator_httpc.erl
index ecd6a3e..985f0c7 100644
--- a/src/couch_replicator_httpc.erl
+++ b/src/couch_replicator_httpc.erl
@@ -35,6 +35,7 @@ setup(#httpdb{httpc_pool = nil, url = Url, http_connections = MaxConns}
= Db) ->
 
 
 send_req(HttpDb, Params1, Callback) ->
+    couch_stats:increment_counter([couch_replicator, requests]),
     Params2 = ?replace(Params1, qs,
         [{K, ?b2l(iolist_to_binary(V))} || {K, V} <- get_value(qs, Params1, [])]),
     Params = ?replace(Params2, ibrowse_options,
@@ -102,6 +103,7 @@ process_response({ibrowse_req_id, ReqId}, Worker, HttpDb, Params, Callback)
->
 process_response({ok, Code, Headers, Body}, Worker, HttpDb, Params, Callback) ->
     case list_to_integer(Code) of
     Ok when (Ok >= 200 andalso Ok < 300) ; (Ok >= 400 andalso Ok < 500) ->
+        couch_stats:increment_counter([couch_replicator, responses, success]),
         EJson = case Body of
         <<>> ->
             null;
@@ -112,6 +114,7 @@ process_response({ok, Code, Headers, Body}, Worker, HttpDb, Params, Callback)
->
     R when R =:= 301 ; R =:= 302 ; R =:= 303 ->
         do_redirect(Worker, R, Headers, HttpDb, Params, Callback);
     Error ->
+        couch_stats:increment_counter([couch_replicator, responses, failure]),
         maybe_retry({code, Error}, Worker, HttpDb, Params)
     end;
 
@@ -138,9 +141,15 @@ process_stream_response(ReqId, Worker, HttpDb, Params, Callback) ->
         R when R =:= 301 ; R =:= 302 ; R =:= 303 ->
             do_redirect(Worker, R, Headers, HttpDb, Params, Callback);
         Error ->
+            couch_stats:increment_counter(
+                [couch_replicator, stream_responses, failure]
+            ),
             report_error(Worker, HttpDb, Params, {code, Error})
         end;
     {ibrowse_async_response, ReqId, {error, _} = Error} ->
+        couch_stats:increment_counter(
+            [couch_replicator, stream_responses, failure]
+        ),
         maybe_retry(Error, Worker, HttpDb, Params)
     after HttpDb#httpdb.timeout + 500 ->
         % Note: ibrowse should always reply with timeouts, but this doesn't


Mime
View raw message