You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2018/03/08 19:39:32 UTC

[couchdb] 01/01: WIP: Testing looking_glass for tracing

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch test-looking-glass
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit a5cbcf8c1189d84f5838e70624667dbe0161cef5
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Thu Mar 8 11:00:33 2018 -0600

    WIP: Testing looking_glass for tracing
---
 rebar.config.script       |  7 ++++++-
 rel/reltool.config        |  8 ++++++--
 src/chttpd/src/chttpd.erl | 12 ++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/rebar.config.script b/rebar.config.script
index c33a71c..ed078f0 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -84,10 +84,15 @@ MakeDep = fun
         {AppName, ".*", {git, Url, Version}, Options}
 end,
 
+ExternalDeps = [
+    {lz4, ".*", {git, "https://github.com/rabbitmq/lz4-erlang", "master"}},
+    {looking_glass, ".*", {git, "https://github.com/rabbitmq/looking_glass.git", "master"}}
+],
+
 AddConfig = [
     {require_otp_vsn, "R16B03|R16B03-1|17|18|19|20"},
     {deps_dir, "src"},
-    {deps, lists:map(MakeDep, DepDescs)},
+    {deps, lists:map(MakeDep, DepDescs) ++ ExternalDeps},
     {sub_dirs, SubDirs},
     {lib_dirs, ["src"]},
     {erl_opts, [debug_info, {i, "../"}]},
diff --git a/rel/reltool.config b/rel/reltool.config
index 464f5f4..bef50ff 100644
--- a/rel/reltool.config
+++ b/rel/reltool.config
@@ -55,7 +55,9 @@
         mochiweb,
         rexi,
         setup,
-        snappy
+        snappy,
+        lz4,
+        looking_glass
     ]},
     {rel, "start_clean", "", [kernel, stdlib]},
     {boot_rel, "couchdb"},
@@ -108,7 +110,9 @@
     {app, mochiweb, [{incl_cond, include}]},
     {app, rexi, [{incl_cond, include}]},
     {app, setup, [{incl_cond, include}]},
-    {app, snappy, [{incl_cond, include}]}
+    {app, snappy, [{incl_cond, include}]},
+    {app, lz4, [{incl_cond, include}]},
+    {app, looking_glass, [{incl_cond, include}]}
 ]}.
 
 {overlay_vars, "couchdb.config"}.
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl
index 6be0d18..258449a 100644
--- a/src/chttpd/src/chttpd.erl
+++ b/src/chttpd/src/chttpd.erl
@@ -142,8 +142,20 @@ stop() ->
 handle_request(MochiReq0) ->
     erlang:put(?REWRITE_COUNT, 0),
     MochiReq = couch_httpd_vhost:dispatch_host(MochiReq0),
+    maybe_trace(MochiReq),
     handle_request_int(MochiReq).
 
+
+maybe_trace(MochiReq) ->
+    case MochiReq:get_header_value("x-couchdb-trace") of
+        "true" ->
+            couch_log:info("Trace initializing...", []),
+            lg:trace(['_', {scope, [self()]}], lg_file_tracer, "traces.lz4", #{mode => profile});
+        _ ->
+            ok
+    end.
+
+
 handle_request_int(MochiReq) ->
     Begin = os:timestamp(),
     case config:get("chttpd", "socket_options") of

-- 
To stop receiving notification emails like this one, please contact
davisp@apache.org.