Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Provide a way to specify consumer connection credentials in HTTP API #25

Merged
merged 3 commits into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ Example for how to create a trace using [RabbitMQ HTTP API](http://www.rabbitmq.
```
curl -i -u guest:guest -H "content-type:application/json" -XPUT \
http://localhost:15672/api/traces/%2f/my-trace \
-d'{"format":"text","pattern":"#", "max_payload_bytes":1000}'
-d'{"format":"text","pattern":"#", "max_payload_bytes":1000,
"tracer_connection_username":"guest", "tracer_connection_password":"guest"}'
```

`max_payload_bytes` is optional (omit it to prevent payload truncation),
format and pattern are mandatory.
The format and pattern fields are mandatory.

`tracer_connection_username` and `tracer_connection_password` control what credentials the tracing
connection will use. Both are optional and default to the configured
plugin values.

`max_payload_bytes` is optional (omit it to prevent payload truncation).
12 changes: 12 additions & 0 deletions priv/www/js/tmpl/traces.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<th>Payload limit</th>
<th>Rate</th>
<th>Queued</th>
<th>Tracer connection username</th>
<th></th>
</tr>
</thead>
Expand Down Expand Up @@ -57,6 +58,7 @@
<div class="status-red"><acronym title="The trace failed to start - check the server logs for details.">FAILED</acronym></div>
</td>
<% } %>
<td><%= fmt_string(trace.tracer_connection_username) %></td>
<td>
<form action="#/traces/node/<%= node.name %>" method="delete">
<input type="hidden" name="vhost" value="<%= fmt_string(trace.vhost) %>"/>
Expand Down Expand Up @@ -142,6 +144,16 @@
</select>
</td>
</tr>
<tr>
<th><label>Tracer connection username:</label></th>
<td><input type="text" name="tracer_connection_username"/></td>
<td><label>Tracer connection password:</label></td>
<td>
<div id="password-div">
<input type="password" name="tracer_connection_password"/>
</div>
</td>
</tr>
<tr>
<th><label>Max payload bytes: <span class="help" id="tracing-max-payload"></span></label></th>
<td>
Expand Down
10 changes: 6 additions & 4 deletions src/rabbit_tracing_consumer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ init(Args) ->
process_flag(trap_exit, true),
Name = pget(name, Args),
VHost = pget(vhost, Args),
Username = rabbit_tracing_util:coerce_env_value(username,
rabbit_misc:get_env(rabbitmq_tracing, username, ?DEFAULT_USERNAME)),
Password = rabbit_tracing_util:coerce_env_value(password,
rabbit_misc:get_env(rabbitmq_tracing, password, ?DEFAULT_PASSWORD)),
Username = pget(tracer_connection_username, Args,
rabbit_misc:get_env(rabbitmq_tracing, username, ?DEFAULT_USERNAME)),
Password = pget(tracer_connection_password, Args,
rabbit_misc:get_env(rabbitmq_tracing, password, ?DEFAULT_PASSWORD)),
Username = rabbit_tracing_util:coerce_env_value(username, Username),
Password = rabbit_tracing_util:coerce_env_value(password, Password),
MaxPayload = pget(max_payload_bytes, Args, unlimited),
{ok, Conn} = amqp_connection:start(
#amqp_params_direct{virtual_host = VHost,
Expand Down
4 changes: 3 additions & 1 deletion src/rabbit_tracing_traces.erl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ vhost_tracing(VHost, Table) ->

augment(Trace) ->
Pid = pget(pid, Trace),
Trace1 = lists:keydelete(pid, 1, Trace),
Trace1 = lists:keydelete(tracer_connection_password, 1,
lists:keydelete(<<"tracer_connection_password">>, 1,
lists:keydelete(pid, 1, Trace))),
case Pid of
undefined -> Trace1;
_ -> rabbit_tracing_consumer:info_all(Pid) ++ Trace1
Expand Down