diff options
author | Loïc Hoguin <[email protected]> | 2017-11-13 20:45:08 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-11-13 20:45:08 +0100 |
commit | a1ad482eb442ea2bd54866656b7a7dc453e4bd8e (patch) | |
tree | 0bd760556b5e9708cb4382e5010e12920291bb35 | |
parent | 6a8f9ebbb27147548356be888e07372245340b20 (diff) | |
download | cowboy-a1ad482eb442ea2bd54866656b7a7dc453e4bd8e.tar.gz cowboy-a1ad482eb442ea2bd54866656b7a7dc453e4bd8e.tar.bz2 cowboy-a1ad482eb442ea2bd54866656b7a7dc453e4bd8e.zip |
Don't supervise the tracer process
If we do then we end up killing the tracer after the stream
terminates and this is not what we want. This prevents us from
getting useful information from requests that are still ongoing
(when they run concurrently) and completely prevents us from
tracing Websocket handlers.
I'm not the biggest fan of having unsupervised modules but if
this is properly documented there should be no problem.
-rw-r--r-- | src/cowboy_tracer_h.erl | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/cowboy_tracer_h.erl b/src/cowboy_tracer_h.erl index b527f7e..914c678 100644 --- a/src/cowboy_tracer_h.erl +++ b/src/cowboy_tracer_h.erl @@ -43,12 +43,8 @@ -spec init(cowboy_stream:streamid(), cowboy_req:req(), cowboy:opts()) -> {cowboy_stream:commands(), any()}. init(StreamID, Req, Opts) -> - Result = init_tracer(StreamID, Req, Opts), - {Commands, Next} = cowboy_stream:init(StreamID, Req, Opts), - case Result of - no_tracing -> {Commands, Next}; - {tracing, TracerPid} -> {[{spawn, TracerPid, 5000}|Commands], Next} - end. + init_tracer(StreamID, Req, Opts), + cowboy_stream:init(StreamID, Req, Opts). -spec data(cowboy_stream:streamid(), cowboy_stream:fin(), cowboy_req:resp_body(), State) -> {cowboy_stream:commands(), State} when State::any(). @@ -75,14 +71,14 @@ early_error(StreamID, Reason, PartialReq, Resp, Opts) -> init_tracer(StreamID, Req, Opts=#{tracer_match_specs := List, tracer_callback := _}) -> case match(List, StreamID, Req, Opts) of false -> - no_tracing; + ok; true -> start_tracer(StreamID, Req, Opts) end; %% When the options tracer_match_specs or tracer_callback %% are not provided we do not enable tracing. init_tracer(_, _, _) -> - no_tracing. + ok. match([], _, _, _) -> true; @@ -129,9 +125,9 @@ start_tracer(StreamID, Req, Opts) -> send, 'receive', call, return_to, procs, ports, monotonic_timestamp, set_on_spawn, {tracer, TracerPid} ]), - {tracing, TracerPid}; + ok; _ -> - no_tracing + ok end. %% Tracer process. |