aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src
diff options
context:
space:
mode:
authorPiotr Dorobisz <[email protected]>2011-03-09 13:47:04 +0100
committerHenrik Nord <[email protected]>2011-08-30 15:22:18 +0200
commitcb2d32fdd68656ed05636456816e51d9654fbbff (patch)
tree8428b889a7f2adc39c22abfd8e77824c4bef7be3 /lib/observer/src
parentb3b322fd0b4d3fbabcf28035f3a62b068f8f3296 (diff)
downloadotp-cb2d32fdd68656ed05636456816e51d9654fbbff.tar.gz
otp-cb2d32fdd68656ed05636456816e51d9654fbbff.tar.bz2
otp-cb2d32fdd68656ed05636456816e51d9654fbbff.zip
Flush file trace port buffers with given frequency
Diffstat (limited to 'lib/observer/src')
-rw-r--r--lib/observer/src/ttb.erl22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/observer/src/ttb.erl b/lib/observer/src/ttb.erl
index 78c065d2eb..24ee94e2d2 100644
--- a/lib/observer/src/ttb.erl
+++ b/lib/observer/src/ttb.erl
@@ -132,10 +132,17 @@ opt([resume|O],{PI,Client,Traci}) ->
opt(O,{PI,Client,[{resume, {true, ?fetch_time}}|Traci]});
opt([{resume,MSec}|O],{PI,Client,Traci}) ->
opt(O,{PI,Client,[{resume, {true, MSec}}|Traci]});
+opt([{flush,MSec}|O],{PI,Client,Traci}) ->
+ opt(O,{PI,Client,[{flush, MSec}|Traci]});
opt([],Opt) ->
ensure_opt(Opt).
ensure_opt({PI,Client,Traci}) ->
+ case {proplists:get_value(flush, Traci), Client} of
+ {undefined, _} -> ok;
+ {_, {local, _}} -> exit(flush_unsupported_with_ip_trace_port);
+ {_,_} -> ok
+ end,
case {proplists:get_value(shell, Traci), Client} of
{undefined, _} -> {PI, Client, Traci};
{true, ?MODULE} -> {PI, {local, ?MODULE}, Traci};
@@ -606,6 +613,7 @@ init(Parent, SessionInfo) ->
ets:new(?history_table,[ordered_set,named_table,public]),
Parent ! {started,self()},
NewSessionInfo = [{partials, 0}, {dead_nodes, []} | SessionInfo],
+ try_send_flush_tick(NewSessionInfo),
loop(dict:new(), NewSessionInfo).
loop(NodeInfo, SessionInfo) ->
@@ -652,6 +660,10 @@ loop(NodeInfo, SessionInfo) ->
{MSec, StopOpts} -> erlang:send_after(MSec, self(), {timeout, StopOpts})
end,
loop(NodeInfo, SessionInfo);
+ flush_timeout ->
+ [ dbg:flush_trace_port(Node) || Node <- dict:fetch_keys(NodeInfo) ],
+ try_send_flush_tick(SessionInfo),
+ loop(NodeInfo, SessionInfo);
{stop,nofetch,Sender} ->
write_config(?last_config, all),
dict:fold(
@@ -668,7 +680,7 @@ loop(NodeInfo, SessionInfo) ->
Localhost = host(node()),
Dir = get_fetch_dir(UserDir),
file:make_dir(Dir),
- %% The nodes are traversed twice here because
+ %% The nodes are traversed twice here because
%% the meta tracing in observer_backend must be
%% stopped before dbg is stopped, and dbg must
%% be stopped before the trace logs are moved orelse
@@ -714,6 +726,14 @@ make_node_alive(Node, SessionInfo) ->
SessionInfo2 = lists:keyreplace(dead_nodes, 1, SessionInfo, {dead_nodes, Dn2}),
{MetaFile, Partials + 1, lists:keyreplace(partials, 1, SessionInfo2, {partials, Partials + 1})}.
+try_send_flush_tick(State) ->
+ case proplists:get_value(flush, State) of
+ undefined ->
+ ok;
+ MSec ->
+ erlang:send_after(MSec, self(), flush_timeout)
+ end.
+
get_fetch_dir(undefined) -> ?upload_dir ++ ts();
get_fetch_dir(Dir) -> Dir.