diff options
| author | Jean-Sébastien Pédron <jean-sebastien.pedron@dumbbell.fr> | 2017-10-04 17:56:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-04 17:56:45 +0200 |
| commit | 2a57ce402353f643b340e01c44d66a34255275c9 (patch) | |
| tree | b97652081d5c7f94ee93725966e9f555638590cb | |
| parent | 3f96e9b69191f7c08bfa0b6f22cf30b82de9a006 (diff) | |
| parent | 0f98949c03ca5a6f18ffcd8a8725b870f8541aac (diff) | |
| download | rabbitmq-server-git-2a57ce402353f643b340e01c44d66a34255275c9.tar.gz | |
Merge pull request #1384 from rabbitmq/integrate-looking_glass
Integrate `looking_glass`
| -rw-r--r-- | src/rabbit.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_looking_glass.erl | 56 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 93f5230250..033379bad1 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -200,6 +200,11 @@ [rabbit_core_metrics_gc]}}, {enables, networking}]}). +-rabbit_boot_step({rabbit_looking_glass, + [{description, "Looking Glass tracer and profiler"}, + {mfa, {rabbit_looking_glass, boot, []}}, + {requires, networking}]}). + %%--------------------------------------------------------------------------- -include("rabbit_framing.hrl"). diff --git a/src/rabbit_looking_glass.erl b/src/rabbit_looking_glass.erl new file mode 100644 index 0000000000..6cd53dbc23 --- /dev/null +++ b/src/rabbit_looking_glass.erl @@ -0,0 +1,56 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License +%% at http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and +%% limitations under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developer of the Original Code is GoPivotal, Inc. +%% Copyright (c) 2007-2017 Pivotal Software, Inc. All rights reserved. +%% + +-module(rabbit_looking_glass). + +-ignore_xref([{lg, trace, 4}]). +-ignore_xref([{maps, from_list, 1}]). + +-export([boot/0]). +-export([connections/0]). + +boot() -> + case os:getenv("RABBITMQ_TRACER") of + false -> + ok; + Value -> + Input = parse_value(Value), + rabbit_log:info( + "Enabling Looking Glass profiler, input value: ~p", + [Input] + ), + {ok, _} = application:ensure_all_started(looking_glass), + lg:trace( + Input, + lg_file_tracer, + "traces.lz4", + maps:from_list([ + {mode, profile}, + {running, true}, + {send, true}] + ) + ) + end. + +parse_value(Value) -> + [begin + [Mod, Fun] = string:tokens(C, ":"), + {callback, list_to_atom(Mod), list_to_atom(Fun)} + end || C <- string:tokens(Value, ",")]. + +connections() -> + Pids = [Pid || {{conns_sup, _}, Pid} <- ets:tab2list(ranch_server)], + [{app, rabbit}, {app, rabbit_common}, {scope, Pids}]. |
