You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2014/08/28 14:00:13 UTC

[50/50] chttpd commit: updated refs/heads/master to 58020ab

Switch to couch_stats application


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

Branch: refs/heads/master
Commit: 58020abb2b8551d196d07fb328e2668eef122342
Parents: fe2a94e
Author: Robert Newson <rn...@apache.org>
Authored: Fri Aug 22 19:10:13 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Aug 22 19:16:48 2014 +0100

----------------------------------------------------------------------
 src/chttpd.app.src        |  1 +
 src/chttpd.erl            | 14 +++++++-------
 src/chttpd_auth_cache.erl |  6 +++---
 src/chttpd_db.erl         |  6 +++---
 src/chttpd_misc.erl       |  2 +-
 src/chttpd_view.erl       |  6 +++---
 6 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/58020abb/src/chttpd.app.src
----------------------------------------------------------------------
diff --git a/src/chttpd.app.src b/src/chttpd.app.src
index 5e63d66..2230849 100644
--- a/src/chttpd.app.src
+++ b/src/chttpd.app.src
@@ -36,6 +36,7 @@
         kernel,
         stdlib,
         couch_log,
+        couch_stats,
         config,
         couch,
         ets_lru,

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/58020abb/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index c9b50ec..760df2d 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -255,13 +255,13 @@ handle_request(MochiReq) ->
     Host = MochiReq:get_header_value("Host"),
     couch_log:notice("~s ~s ~s ~s ~s ~B ~p ~B", [get(nonce), Peer, Host,
         atom_to_list(Method1), RawUri, Code, Status, round(RequestTime)]),
-    couch_stats_collector:record({couchdb, request_time}, RequestTime),
+    couch_stats:update_histogram([couchdb, request_time], RequestTime),
     case Result of
     {ok, _} ->
-        couch_stats_collector:increment({httpd, requests}),
+        couch_stats:increment_counter([httpd, requests]),
         {ok, Resp};
     {aborted, _, Reason} ->
-        couch_stats_collector:increment({httpd, aborted_requests}),
+        couch_stats:increment_counter([httpd, aborted_requests]),
         couch_log:error("Response abnormally terminated: ~p", [Reason]),
         exit(normal)
     end.
@@ -355,7 +355,7 @@ authenticate_request(Response, _AuthFuns) ->
     Response.
 
 increment_method_stats(Method) ->
-    couch_stats_collector:increment({httpd_request_methods, Method}).
+    couch_stats:increment_counter([httpd_request_methods, Method]).
 
 url_handler("") ->              fun chttpd_misc:handle_welcome_req/1;
 url_handler("favicon.ico") ->   fun chttpd_misc:handle_favicon_req/1;
@@ -557,7 +557,7 @@ verify_is_server_admin(#httpd{user_ctx=#user_ctx{roles=Roles}}) ->
     end.
 
 start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers0, Length) ->
-    couch_stats_collector:increment({httpd_status_codes, Code}),
+    couch_stats:increment_counter([httpd_status_codes, Code]),
     Headers = Headers0 ++ server_header() ++
 	couch_httpd_auth:cookie_auth_header(Req, Headers0),
     Resp = MochiReq:start_response_length({Code,
@@ -573,7 +573,7 @@ send(Resp, Data) ->
     {ok, Resp}.
 
 start_chunked_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers0) ->
-    couch_stats_collector:increment({httpd_status_codes, Code}),
+    couch_stats:increment_counter([httpd_status_codes, Code]),
     Headers = Headers0 ++ server_header() ++
         couch_httpd_auth:cookie_auth_header(Req, Headers0),
     Resp = MochiReq:respond({Code, chttpd_cors:headers(Req, Headers),
@@ -589,7 +589,7 @@ send_chunk(Resp, Data) ->
     {ok, Resp}.
 
 send_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers0, Body) ->
-    couch_stats_collector:increment({httpd_status_codes, Code}),
+    couch_stats:increment_counter([httpd_status_codes, Code]),
     Headers = Headers0 ++ server_header() ++
 	[timing(), reqid() | couch_httpd_auth:cookie_auth_header(Req, Headers0)],
     {ok, MochiReq:respond({Code, Headers, Body})}.

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/58020abb/src/chttpd_auth_cache.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_auth_cache.erl b/src/chttpd_auth_cache.erl
index 14fd3ce..55f746e 100644
--- a/src/chttpd_auth_cache.erl
+++ b/src/chttpd_auth_cache.erl
@@ -52,18 +52,18 @@ get_user_creds(UserName) when is_binary(UserName) ->
 get_from_cache(UserName) ->
     try ets_lru:lookup_d(?CACHE, UserName) of
 	{ok, Props} ->
-	    couch_stats_collector:increment({chttpd, auth_cache_hits}),
+	    couch_stats:increment_counter([chttpd, auth_cache_hits]),
 	    couch_log:debug("cache hit for ~s", [UserName]),
 	    Props;
 	_ ->
 	    Props = load_user_from_db(UserName),
-	    couch_stats_collector:increment({chttpd, auth_cache_misses}),
+	    couch_stats:increment_counter([chttpd, auth_cache_misses]),
 	    couch_log:debug("cache miss for ~s", [UserName]),
 	    ets_lru:insert(?CACHE, UserName, Props),
 	    Props
     catch
 	error:badarg ->
-	    couch_stats_collector:increment({chttpd, auth_cache_misses}),
+	    couch_stats:increment_counter([chttpd, auth_cache_misses]),
 	    couch_log:debug("cache miss for ~s", [UserName]),
 	    load_user_from_db(UserName)
     end.

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/58020abb/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 14e9594..1846e76 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -67,7 +67,7 @@ handle_changes_req(#httpd{method='GET'}=Req, Db) ->
         {ok, Info} = fabric:get_db_info(Db),
         Etag = chttpd:make_etag(Info),
         DeltaT = timer:now_diff(os:timestamp(), T0) / 1000,
-        couch_stats_collector:record({couchdb, dbinfo}, DeltaT),
+        couch_stats:update_histogram([couchdb, dbinfo], DeltaT),
         chttpd:etag_respond(Req, Etag, fun() ->
             fabric:changes(Db, fun changes_callback/2, {"normal", {"Etag",Etag}, Req},
                 ChangesArgs)
@@ -252,7 +252,7 @@ db_req(#httpd{method='GET',path_parts=[DbName]}=Req, _Db) ->
     T0 = os:timestamp(),
     {ok, DbInfo} = fabric:get_db_info(DbName),
     DeltaT = timer:now_diff(os:timestamp(), T0) / 1000,
-    couch_stats_collector:record({couchdb, dbinfo}, DeltaT),
+    couch_stats:update_histogram([couchdb, dbinfo], DeltaT),
     send_json(Req, {DbInfo});
 
 db_req(#httpd{method='POST', path_parts=[DbName], user_ctx=Ctx}=Req, Db) ->
@@ -314,7 +314,7 @@ db_req(#httpd{path_parts=[_,<<"_ensure_full_commit">>]}=Req, _Db) ->
     send_method_not_allowed(Req, "POST");
 
 db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>], user_ctx=Ctx}=Req, Db) ->
-    couch_stats_collector:increment({httpd, bulk_requests}),
+    couch_stats:increment_counter([httpd, bulk_requests]),
     couch_httpd:validate_ctype(Req, "application/json"),
     {JsonProps} = chttpd:json_body_obj(Req),
     DocsArray = case couch_util:get_value(<<"docs">>, JsonProps) of

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/58020abb/src/chttpd_misc.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_misc.erl b/src/chttpd_misc.erl
index c1c805d..dea85e3 100644
--- a/src/chttpd_misc.erl
+++ b/src/chttpd_misc.erl
@@ -307,7 +307,7 @@ handle_system_req(Req) ->
     ]}).
 
 db_pid_stats() ->
-    {monitors, M} = process_info(whereis(couch_stats_collector), monitors),
+    {monitors, M} = process_info(whereis(couch_stats_process_tracker), monitors),
     Candidates = [Pid || {process, Pid} <- M],
     CouchFiles = db_pid_stats(couch_file, Candidates),
     CouchDbUpdaters = db_pid_stats(couch_db_updater, Candidates),

http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/58020abb/src/chttpd_view.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_view.erl b/src/chttpd_view.erl
index 7e5f32f..ffdfe2b 100644
--- a/src/chttpd_view.erl
+++ b/src/chttpd_view.erl
@@ -63,7 +63,7 @@ design_doc_view(Req, Db, DDoc, ViewName, Keys) ->
 
 handle_view_req(#httpd{method='GET',
         path_parts=[_, _, _, _, ViewName]}=Req, Db, DDoc) ->
-    couch_stats_collector:increment({httpd, view_reads}),
+    couch_stats:increment_counter([httpd, view_reads]),
     Keys = chttpd:qs_json_value(Req, "keys", undefined),
     design_doc_view(Req, Db, DDoc, ViewName, Keys);
 
@@ -74,10 +74,10 @@ handle_view_req(#httpd{method='POST',
     Queries = couch_mrview_util:get_view_queries(Props),
     case {Queries, Keys} of
         {Queries, undefined} when is_list(Queries) ->
-            [couch_stats_collector:increment({httpd, view_reads}) || _I <- Queries],
+            [couch_stats:increment_counter([httpd, view_reads]) || _I <- Queries],
             multi_query_view(Req, Db, DDoc, ViewName, Queries);
         {undefined, Keys} when is_list(Keys) ->
-            couch_stats_collector:increment({httpd, view_reads}),
+            couch_stats:increment_counter([httpd, view_reads]),
             design_doc_view(Req, Db, DDoc, ViewName, Keys);
         {undefined, undefined} ->
             throw({