From a5cbcf8c1189d84f5838e70624667dbe0161cef5 Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Thu, 8 Mar 2018 11:00:33 -0600 Subject: 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 c33a71cb5..ed078f068 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 464f5f4fe..bef50ff12 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 6be0d1848..258449a79 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 -- cgit v1.2.1