Переглянути джерело

ft: 文件名修改

master
SisMaker 3 роки тому
джерело
коміт
2a8411d11f
18 змінених файлів з 47 додано та 100 видалено
  1. +2
    -2
      src/eTpf.erl
  2. +5
    -4
      src/eTpf_sup.erl
  3. +0
    -25
      src/profile/looking_glass_app.erl
  4. +0
    -29
      src/profile/looking_glass_sup.erl
  5. +2
    -2
      src/profile/tpCallgrind.erl
  6. +1
    -1
      src/profile/tpFileReader.erl
  7. +2
    -2
      src/profile/tpFileTracer.erl
  8. +3
    -3
      src/profile/tpFlame.erl
  9. +3
    -3
      src/profile/tpMessages.erl
  10. +3
    -3
      src/profile/tpMessagesSeqdiag.erl
  11. +1
    -1
      src/profile/tpRabbitHole.erl
  12. +1
    -1
      src/profile/tpRawConsoleTracer.erl
  13. +1
    -1
      src/profile/tpSocketClient.erl
  14. +1
    -1
      src/profile/tpSocketTracer.erl
  15. +1
    -1
      src/profile/tpTerm.erl
  16. +1
    -1
      src/profile/tpTracer.erl
  17. +1
    -1
      src/profile/tpTracerPool.erl
  18. +19
    -19
      test/lg_SUITE.erl

+ 2
- 2
src/eTpf.erl Переглянути файл

@ -43,7 +43,7 @@ running => boolean()
-spec trace(user_input()) -> ok.
trace(Input) ->
trace(Input, lg_raw_console_tracer).
trace(Input, tpRawConsoleTracer).
-spec trace(user_input(), module()) -> ok.
trace(Input, TracerMod) ->
@ -72,7 +72,7 @@ do_trace(Input0, TracerMod, TracerOpts, Opts) ->
restart => temporary,
type => supervisor
}),
Tracers = lg_tracer_pool:tracers(PoolPid),
Tracers = tpTracerPool:tracers(PoolPid),
TracersMap = maps:from_list(lists:zip(lists:seq(0, length(Tracers) - 1), Tracers)),
Mode = maps:get(mode, Opts, trace),
Input1 = flatten(Input0, []),

+ 5
- 4
src/eTpf_sup.erl Переглянути файл

@ -26,10 +26,11 @@ start_link() ->
%% type => worker(), % optional
%% modules => modules()} % optional
init([]) ->
SupFlags = #{strategy => one_for_all,
intensity => 0,
period => 1},
ChildSpecs = [],
SupFlags = #{strategy => one_for_one,
intensity => 5,
period => 10},
ChildSpecs = [ {lg_rabbit_hole, {lg_rabbit_hole, start_link, []},
permanent, 5000, worker, [lg_rabbit_hole]}],
{ok, {SupFlags, ChildSpecs}}.
%% internal functions

+ 0
- 25
src/profile/looking_glass_app.erl Переглянути файл

@ -1,25 +0,0 @@
%% Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved.
%%
%% This package, Looking Glass, is double-licensed under the Mozilla
%% Public License 1.1 ("MPL") and the Apache License version 2
%% ("ASL"). For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL,
%% please see LICENSE-APACHE2.
%%
%% This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
%% either express or implied. See the LICENSE file for specific language governing
%% rights and limitations of this software.
%%
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(looking_glass_app).
-behaviour(application).
-export([start/2]).
-export([stop/1]).
start(_Type, _Args) ->
looking_glass_sup:start_link().
stop(_State) ->
ok.

+ 0
- 29
src/profile/looking_glass_sup.erl Переглянути файл

@ -1,29 +0,0 @@
%% Copyright (c) 2017-Present Pivotal Software, Inc. All rights reserved.
%%
%% This package, Looking Glass, is double-licensed under the Mozilla
%% Public License 1.1 ("MPL") and the Apache License version 2
%% ("ASL"). For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL,
%% please see LICENSE-APACHE2.
%%
%% This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
%% either express or implied. See the LICENSE file for specific language governing
%% rights and limitations of this software.
%%
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(looking_glass_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
Procs = [
{lg_rabbit_hole, {lg_rabbit_hole, start_link, []},
permanent, 5000, worker, [lg_rabbit_hole]}
],
{ok, {{one_for_one, 1, 5}, Procs}}.

src/profile/lg_callgrind.erl → src/profile/tpCallgrind.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_callgrind).
-module(tpCallgrind).
-export([patterns/0]).
-export([profile/2]).
@ -93,7 +93,7 @@ profile(Input, Output, Opts) ->
{ok, OutDevice} = file:open(Output, [write]),
State = #state{input = Input, output = Output, output_device = OutDevice, opts = Opts},
write_header(State),
{ok, FinalState} = lg_file_reader:fold(fun handle_event/2, State, Input),
{ok, FinalState} = tpFileReader:fold(fun handle_event/2, State, Input),
flush(FinalState),
_ = file:close(OutDevice),
ok.

src/profile/lg_file_reader.erl → src/profile/tpFileReader.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_file_reader).
-module(tpFileReader).
-export([fold/3]).
-export([foreach/2]).

src/profile/lg_file_tracer.erl → src/profile/tpFileTracer.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_file_tracer).
-module(tpFileTracer).
-export([start_link/2]).
-export([init/3]).
@ -60,7 +60,7 @@ loop(State = #state{parent = Parent, size = Size, io_device = IoDevice,
{system, From, Request} ->
sys:handle_system_msg(Request, From, Parent, ?MODULE, [], State);
Msg0 ->
Msg = lg_term:truncate(Msg0),
Msg = tpTerm:truncate(Msg0),
Bin = term_to_binary(Msg),
BinSize = byte_size(Bin),
Buffer = <<Buffer0/binary, BinSize:32, Bin/binary>>,

src/profile/lg_flame.erl → src/profile/tpFlame.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_flame).
-module(tpFlame).
-export([profile/2]).
-export([profile_many/2]).
@ -27,7 +27,7 @@
-spec profile(file:filename_all(), file:filename_all()) -> ok.
profile(Input, Output) ->
InitialState = exp1_init(Output),
{ok, FinalState} = lg_file_reader:fold(fun handle_event/2, InitialState, Input),
{ok, FinalState} = tpFileReader:fold(fun handle_event/2, InitialState, Input),
flush(FinalState).
-spec profile_many(file:filename(), file:filename()) -> ok.
@ -35,7 +35,7 @@ profile_many(Wildcard, Output) ->
InitialState = exp1_init(Output),
Files = filelib:wildcard(Wildcard),
FinalState = lists:foldl(fun(Input, State0) ->
case lg_file_reader:fold(fun handle_event/2, State0, Input) of
case tpFileReader:fold(fun handle_event/2, State0, Input) of
{ok, State} ->
State;
{error, Reason, HumanReadable} ->

src/profile/lg_messages.erl → src/profile/tpMessages.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_messages).
-module(tpMessages).
-export([profile/1]).
-export([profile_many/1]).
@ -28,14 +28,14 @@
-spec profile(file:filename_all()) -> ok.
profile(Input) ->
{ok, FinalState} = lg_file_reader:fold(fun handle_event/2, #state{}, Input),
{ok, FinalState} = tpFileReader:fold(fun handle_event/2, #state{}, Input),
flush(FinalState).
-spec profile_many(file:filename()) -> ok.
profile_many(Wildcard) ->
Files = filelib:wildcard(Wildcard),
FinalState = lists:foldl(fun(Input, State0) ->
{ok, State} = lg_file_reader:fold(fun handle_event/2, State0, Input),
{ok, State} = tpFileReader:fold(fun handle_event/2, State0, Input),
State
end, #state{}, Files),
flush(FinalState).

src/profile/lg_messages_seqdiag.erl → src/profile/tpMessagesSeqdiag.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_messages_seqdiag).
-module(tpMessagesSeqdiag).
-export([profile/2]).
-export([profile_many/2]).
@ -25,7 +25,7 @@
-spec profile(file:filename_all(), list()) -> ok.
profile(Input, Pids) ->
{ok, FinalState} = lg_file_reader:fold(fun handle_event/2,
{ok, FinalState} = tpFileReader:fold(fun handle_event/2,
#state{pids = prepare_pids(Pids)}, Input),
flush(FinalState).
@ -33,7 +33,7 @@ profile(Input, Pids) ->
profile_many(Wildcard, Pids) ->
Files = filelib:wildcard(Wildcard),
FinalState = lists:foldl(fun(Input, State0) ->
{ok, State} = lg_file_reader:fold(fun handle_event/2, State0, Input),
{ok, State} = tpFileReader:fold(fun handle_event/2, State0, Input),
State
end, #state{pids = prepare_pids(Pids)}, Files),
flush(FinalState).

src/profile/lg_rabbit_hole.erl → src/profile/tpRabbitHole.erl Переглянути файл

@ -18,7 +18,7 @@
%% the sending of messages. This process does not need them, it
%% just needs to exist, and therefore it discards everything.
-module(lg_rabbit_hole).
-module(tpRabbitHole).
-behaviour(gen_server).
%% API.

src/profile/lg_raw_console_tracer.erl → src/profile/tpRawConsoleTracer.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_raw_console_tracer).
-module(tpRawConsoleTracer).
-export([start_link/2]).
-export([init/1]).

src/profile/lg_socket_client.erl → src/profile/tpSocketClient.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_socket_client).
-module(tpSocketClient).
-behavior(gen_statem).
-export([start_link/2]).

src/profile/lg_socket_tracer.erl → src/profile/tpSocketTracer.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_socket_tracer).
-module(tpSocketTracer).
-export([start_link/2]).
-export([init/2]).

src/profile/lg_term.erl → src/profile/tpTerm.erl Переглянути файл

@ -15,7 +15,7 @@
%% Going for hardcoded values for now. We can't spend time
%% looking up inside a record or map for this.
-module(lg_term).
-module(tpTerm).
-export([truncate/1]).
-export([truncate/2]).

src/profile/lg_tracer.erl → src/profile/tpTracer.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_tracer).
-module(tpTracer).
%-behavior(erl_tracer).
-export([enabled/3]).

src/profile/lg_tracer_pool.erl → src/profile/tpTracerPool.erl Переглянути файл

@ -12,7 +12,7 @@
%% If you have any questions regarding licensing, please contact us at
%% info@rabbitmq.com.
-module(lg_tracer_pool).
-module(tpTracerPool).
-behaviour(supervisor).
-export([start_link/3]).

+ 19
- 19
test/lg_SUITE.erl Переглянути файл

@ -18,14 +18,14 @@ groups() ->
app(Config) ->
doc("Trace a specific application."),
eTpf:trace({app, stdlib}, lg_file_tracer, config(priv_dir, Config) ++ "/app.lz4"),
eTpf:trace({app, stdlib}, tpFileTracer, config(priv_dir, Config) ++ "/app.lz4"),
lists:seq(1, 10),
eTpf:stop(),
do_ensure_decompress(config(priv_dir, Config) ++ "/app.lz4").
callback(Config) ->
doc("Trace using patterns from a callback function."),
eTpf:trace({callback, ?MODULE, do_callback}, lg_file_tracer,
eTpf:trace({callback, ?MODULE, do_callback}, tpFileTracer,
config(priv_dir, Config) ++ "/callback.lz4"),
lists:seq(1, 10),
eTpf:stop(),
@ -37,12 +37,12 @@ do_callback() ->
callgrind_running(Config) ->
doc("Save events to files on disk then build callgrind files."),
PrivDir = config(priv_dir, Config),
eTpf:trace([{scope, [self()]}, ?MODULE, {app, stdlib}], lg_file_tracer,
eTpf:trace([{scope, [self()]}, ?MODULE, {app, stdlib}], tpFileTracer,
PrivDir ++ "/callgrind_running.lz4",
#{mode => profile, running => true}),
do_callgrind_running(),
eTpf:stop(),
lg_callgrind:profile_many(
tpCallgrind:profile_many(
PrivDir ++ "/callgrind_running.lz4.*",
PrivDir ++ "/callgrind_running.out",
#{running => true}),
@ -75,12 +75,12 @@ callgrind_running_cycle(Config) ->
doc("Save events to files on disk then build callgrind files. "
"Create a recursive cycle using two functions calling each other."),
PrivDir = config(priv_dir, Config),
eTpf:trace([{scope, [self()]}, ?MODULE, {app, stdlib}], lg_file_tracer,
eTpf:trace([{scope, [self()]}, ?MODULE, {app, stdlib}], tpFileTracer,
PrivDir ++ "/callgrind_running_cycle.lz4",
#{mode => profile, running => true}),
do_callgrind_running_cycle(),
eTpf:stop(),
lg_callgrind:profile_many(
tpCallgrind:profile_many(
PrivDir ++ "/callgrind_running_cycle.lz4.*",
PrivDir ++ "/callgrind_running_cycle.out",
#{running => true}),
@ -126,7 +126,7 @@ do_callgrind_running_cycle2(Ref) ->
file_tracer(Config) ->
doc("Save events to files on disk."),
eTpf:trace(lists, lg_file_tracer, config(priv_dir, Config) ++ "/file_tracer.lz4"),
eTpf:trace(lists, tpFileTracer, config(priv_dir, Config) ++ "/file_tracer.lz4"),
lists:seq(1, 10),
eTpf:stop(),
do_ensure_decompress(config(priv_dir, Config) ++ "/file_tracer.lz4").
@ -134,7 +134,7 @@ file_tracer(Config) ->
file_tracer_rotation(Config) ->
doc("Save events to files on disk; rotate the files if they get too big."),
Prefix = config(priv_dir, Config) ++ "/file_tracer.lz4",
eTpf:trace(lists, lg_file_tracer, #{
eTpf:trace(lists, tpFileTracer, #{
filename_prefix => Prefix,
max_size => 100, %% Intentionally low.
events_per_frame => 10 %% Needed to trigger the rotation, default is too high.
@ -151,14 +151,14 @@ file_tracer_rotation(Config) ->
mod(Config) ->
doc("Trace a specific module."),
eTpf:trace(lists, lg_file_tracer, config(priv_dir, Config) ++ "/mod.lz4"),
eTpf:trace(lists, tpFileTracer, config(priv_dir, Config) ++ "/mod.lz4"),
lists:seq(1, 10),
eTpf:stop(),
do_ensure_decompress(config(priv_dir, Config) ++ "/mod.lz4").
profile_mode(Config) ->
doc("Trace a specific module in profile mode."),
eTpf:trace(lists, lg_file_tracer, config(priv_dir, Config) ++ "/profile_mode.lz4",
eTpf:trace(lists, tpFileTracer, config(priv_dir, Config) ++ "/profile_mode.lz4",
#{mode => profile}),
lists:seq(1, 10),
eTpf:stop(),
@ -175,7 +175,7 @@ raw_console_tracer(_) ->
running_true(Config) ->
doc("Trace a specific module with running option enabled."),
eTpf:trace(lists, lg_file_tracer, config(priv_dir, Config) ++ "/running_true.lz4",
eTpf:trace(lists, tpFileTracer, config(priv_dir, Config) ++ "/running_true.lz4",
#{running => true}),
lists:seq(1, 10),
eTpf:stop(),
@ -183,7 +183,7 @@ running_true(Config) ->
send_true(Config) ->
doc("Trace a specific module with send option enabled."),
eTpf:trace(lists, lg_file_tracer, config(priv_dir, Config) ++ "/send_true.lz4",
eTpf:trace(lists, tpFileTracer, config(priv_dir, Config) ++ "/send_true.lz4",
#{send => true}),
Self = self(),
%% Send a message to and from an existing process.
@ -204,7 +204,7 @@ send_true(Config) ->
socket_tracer(_) ->
doc("Send events to a socket."),
Port = 61234,
eTpf:trace(lists, lg_socket_tracer, Port, #{pool_size => 1}),
eTpf:trace(lists, tpSocketTracer, Port, #{pool_size => 1}),
{ok, Socket} = gen_tcp:connect("localhost", Port,
[binary, {packet, 2}, {active, true}]),
lists:seq(1, 10),
@ -214,13 +214,13 @@ socket_tracer(_) ->
socket_tracer_client(Config) ->
doc("Send events to a socket client."),
Port = 61234,
eTpf:trace(lists, lg_socket_tracer, Port, #{pool_size => 1}),
eTpf:trace(lists, tpSocketTracer, Port, #{pool_size => 1}),
BaseFilename = config(priv_dir, Config) ++ "/socket_tracer_client.lz4",
{ok, Pid} = lg_socket_client:start_link(Port, BaseFilename),
{ok, Pid} = tpSocketClient:start_link(Port, BaseFilename),
timer:sleep(1000),
lists:seq(1, 10),
eTpf:stop(),
lg_socket_client:stop(Pid),
tpSocketClient:stop(Pid),
{ok, File} = file:read_file(BaseFilename ++ ".0"),
_ = lz4f:decompress(File),
true = filelib:file_size(BaseFilename ++ ".0") > 0,
@ -229,7 +229,7 @@ socket_tracer_client(Config) ->
socket_tracer_many(_) ->
doc("Send events to many sockets."),
Port = 61234,
eTpf:trace(lists, lg_socket_tracer, Port, #{pool_size => 5}),
eTpf:trace(lists, tpSocketTracer, Port, #{pool_size => 5}),
{ok, _} = gen_tcp:connect("localhost", Port, []),
{ok, _} = gen_tcp:connect("localhost", Port + 1, []),
{ok, _} = gen_tcp:connect("localhost", Port + 2, []),
@ -241,7 +241,7 @@ socket_tracer_many(_) ->
socket_tracer_reconnect(_) ->
doc("Confirm we can reconnect to the tracer."),
Port = 61234,
eTpf:trace(lists, lg_socket_tracer, Port, #{pool_size => 1}),
eTpf:trace(lists, tpSocketTracer, Port, #{pool_size => 1}),
{ok, Socket0} = gen_tcp:connect("localhost", Port,
[binary, {packet, 2}, {active, true}]),
ok = gen_tcp:close(Socket0),
@ -267,7 +267,7 @@ stop_while_trace_is_running(Config) ->
doc("Stop tracing while events are still coming in."),
Self = self(),
Pid = spawn_link(fun() -> Self ! {self(), continue}, lists:seq(1, 10000000) end),
eTpf:trace([{scope, [Pid]}, lists], lg_file_tracer,
eTpf:trace([{scope, [Pid]}, lists], tpFileTracer,
config(priv_dir, Config) ++ "/stop_while_trace_is_running.lz4"),
receive {Pid, continue} -> ok after 100 -> error(timeout) end,
eTpf:stop(),

Завантаження…
Відмінити
Зберегти