couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r778072 - in /couchdb/trunk/src/couchdb: couch_httpd_db.erl couch_stats_aggregator.erl couch_stats_collector.erl
Date Sun, 24 May 2009 00:04:36 GMT
Author: damien
Date: Sun May 24 00:04:36 2009
New Revision: 778072

URL: http://svn.apache.org/viewvc?rev=778072&view=rev
Log:
Added stats tracking for active _changes clients.

Modified:
    couchdb/trunk/src/couchdb/couch_httpd_db.erl
    couchdb/trunk/src/couchdb/couch_stats_aggregator.erl
    couchdb/trunk/src/couchdb/couch_stats_collector.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=778072&r1=778071&r2=778072&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Sun May 24 00:04:36 2009
@@ -51,18 +51,21 @@
     case couch_httpd:qs_value(Req, "continuous", "false") of
     "true" ->
         Self = self(),
-        Notify = couch_db_update_notifier:start_link(
+        {ok, Notify} = couch_db_update_notifier:start_link(
             fun({_, DbName0}) when DbName0 == DbName ->
                 Self ! db_updated;
             (_) ->
                 ok
             end),
+        couch_stats_collector:track_process_count(Self,
+                            {httpd, clients_requesting_changes}),
         try
             keep_sending_changes(Req, Resp, Db, StartSeq, <<"">>)
         after
-            catch couch_db_update_notifier:stop(Notify),
+            couch_db_update_notifier:stop(Notify),
             wait_db_updated(0) % clean out any remaining update messages
         end;
+        
     "false" ->
         {ok, {LastSeq, _Prepend}} = 
                 send_changes(Req, Resp, Db, StartSeq, <<"">>),

Modified: couchdb/trunk/src/couchdb/couch_stats_aggregator.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_stats_aggregator.erl?rev=778072&r1=778071&r2=778072&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_stats_aggregator.erl (original)
+++ couchdb/trunk/src/couchdb/couch_stats_aggregator.erl Sun May 24 00:04:36 2009
@@ -309,6 +309,7 @@
     ets:insert(?MODULE, {{httpd, requests}, <<"number of HTTP requests">>}),
     ets:insert(?MODULE, {{httpd, temporary_view_reads}, <<"number of temporary view
reads">>}),
     ets:insert(?MODULE, {{httpd, view_reads}, <<"number of view reads">>}),
+    ets:insert(?MODULE, {{httpd, clients_requesting_changes}, <<"Number of clients
currently requesting continuous _changes">>}),
     
     ets:insert(?MODULE, {{httpd_request_methods, 'COPY'}, <<"number of HTTP COPY requests">>}),
     ets:insert(?MODULE, {{httpd_request_methods, 'DELETE'}, <<"number of HTTP DELETE
requests">>}),

Modified: couchdb/trunk/src/couchdb/couch_stats_collector.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_stats_collector.erl?rev=778072&r1=778071&r2=778072&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_stats_collector.erl (original)
+++ couchdb/trunk/src/couchdb/couch_stats_collector.erl Sun May 24 00:04:36 2009
@@ -24,7 +24,7 @@
 
 -export([start/0, stop/0, get/1, 
         increment/1, decrement/1,
-        track_process_count/1,
+        track_process_count/1, track_process_count/2,
         record/2, clear/1,
         all/0, all/1]).
 
@@ -87,14 +87,15 @@
         absolute -> ets:tab2list(?ABSOLUTE_VALUE_COUNTER_TABLE)
     end.
 
-
 track_process_count(Stat) ->
+    track_process_count(self(), Stat).
+
+track_process_count(Pid, Stat) ->
     case (catch couch_stats_collector:increment(Stat)) of
     ok ->
-        Self = self(),
         spawn(
             fun() ->
-                erlang:monitor(process, Self),
+                erlang:monitor(process, Pid),
                 receive {'DOWN', _, _, _, _} -> ok end,
                 couch_stats_collector:decrement(Stat)
             end);



Mime
View raw message