Skip to content

Commit da1705e

Browse files
Merge pull request #16006 from rabbitmq/revert-15975-connection-info-disable-metrics-conn
Revert "HTTP API: Display static connection info when stats are disabled"
2 parents ac583d5 + 49d4f13 commit da1705e

9 files changed

Lines changed: 34 additions & 79 deletions

File tree

deps/rabbitmq_management/priv/www/js/formatters.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,6 @@ function group_count(mode, group, bools) {
971971
var options = COLUMNS[mode][group];
972972
for (var i = 0; i < options.length; i++) {
973973
var column = options[i][0];
974-
if (mode === 'connections' && disable_stats &&
975-
(column === 'from_client' || column === 'to_client')) {
976-
continue;
977-
}
978974
if (show_column(mode, column)) count++;
979975
}
980976
return count;

deps/rabbitmq_management/priv/www/js/global.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,8 @@ var DISABLED_STATS_COLUMNS =
170170
['msgs-persistent', 'Persistent', false],
171171
['msgs-total', 'Total', true]]},
172172
'connections':
173-
{'Overview': [['container_id', 'Container ID', true],
174-
['user', 'User name', true]],
175-
'Details': [['ssl', 'TLS', true],
176-
['ssl_info', 'TLS details', false],
177-
['protocol', 'Protocol', true],
178-
['channel_max', 'Channel max', false],
179-
['frame_max', 'Frame max', false],
180-
['auth_mechanism', 'SASL auth mechanism', false],
181-
['client', 'Client', false]],
182-
'Network': [['from_client', 'From client', false],
183-
['to_client', 'To client', false],
184-
['heartbeat', 'Heartbeat', false],
185-
['connected_at', 'Connected at', false]]},
173+
{'Overview': [['user', 'User name', true],
174+
['state', 'State', true]]},
186175

187176
'vhosts':
188177
{'Overview': [['cluster-state', 'Cluster state', false]]}};

deps/rabbitmq_management/priv/www/js/tmpl/columns-options.ejs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
<tr>
1616
<th><label><%= group %>:</label></th>
1717
<td>
18-
<% for (var i = 0; i < options.length; i++) {
19-
if (mode === 'connections' && disable_stats &&
20-
(options[i][0] === 'from_client' || options[i][0] === 'to_client')) {
21-
continue;
22-
}
23-
%>
18+
<% for (var i = 0; i < options.length; i++) { %>
2419
<%= fmt_checkbox(mode + '-' + options[i][0], options[i][1], get_pref('column-' + mode + '-' + options[i][0]) == 'true') %>
2520
<% } %>
2621
</td>

deps/rabbitmq_management/priv/www/js/tmpl/connection.ejs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<h2>Connection <%= fmt_string(connection.name) %> <%= fmt_maybe_vhost(connection.vhost) %></h1>
22

3+
<% if (!disable_stats) { %>
34
<div class="section" id="connection-overview-section">
45
<h2>Overview</h2>
56
<div class="hider updatable">
6-
<% if (!disable_stats) { %>
77
<%= data_rates('data-rates-conn', connection, 'Data rates') %>
8-
<% } %>
98
109
<h3>Details</h3>
1110
<table class="facts facts-l">
@@ -84,7 +83,6 @@
8483
</div>
8584
</div>
8685
87-
<% if (!disable_stats) { %>
8886
<% if (connection.protocol === 'AMQP 1-0' ||
8987
connection.protocol === 'Web AMQP 1-0') { %>
9088
@@ -104,7 +102,6 @@
104102
</div>
105103
</div>
106104
107-
<% } %>
108105
<% } %>
109106
110107
<% if (connection.ssl) { %>
@@ -160,7 +157,7 @@
160157
</div>
161158
<% } %>
162159
163-
<% if (!disable_stats && (connection.reductions || connection.garbage_collection)) { %>
160+
<% if(connection.reductions || connection.garbage_collection) { %>
164161
<div class="section-hidden" id="connection-runtime-metrics-section">
165162
<h2>Runtime Metrics (Advanced)</h2>
166163
<div class="hider updatable">
@@ -197,6 +194,7 @@
197194
</div>
198195
</div>
199196
197+
<% } %>
200198
<% } %>
201199

202200
<div class="section-hidden" id="connection-close-section">

deps/rabbitmq_management/priv/www/js/tmpl/connections.ejs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
<thead>
99
<tr>
1010
<%= group_heading('connections', 'Overview', [vhosts_interesting, nodes_interesting, true]) %>
11+
<% if (!disable_stats) { %>
1112
<%= group_heading('connections', 'Details', []) %>
1213
<%= group_heading('connections', 'Network', []) %>
14+
<% } %>
1315
<th class="plus-minus"><span class="popup-options-link" title="Click to change columns" type="columns" for="connections">+/-</span></th>
1416
</tr>
1517
<tr>
@@ -30,7 +32,8 @@
3032
<% if (show_column('connections', 'user')) { %>
3133
<th><%= fmt_sort('User name', 'user') %></th>
3234
<% } %>
33-
<% if (show_column('connections', 'state') && !disable_stats) { %>
35+
<% if (!disable_stats) { %>
36+
<% if (show_column('connections', 'state')) { %>
3437
<th><%= fmt_sort('State', 'state') %></th>
3538
<% } %>
3639
<% if (show_column('connections', 'ssl')) { %>
@@ -42,7 +45,7 @@
4245
<% if (show_column('connections', 'protocol')) { %>
4346
<th><%= fmt_sort('Protocol', 'protocol') %></th>
4447
<% } %>
45-
<% if (show_column('connections', 'channels') && !disable_stats) { %>
48+
<% if (show_column('connections', 'channels')) { %>
4649
<th><%= fmt_sort('Channels', 'channels') %></th>
4750
<% } %>
4851
<% if (show_column('connections', 'channel_max')) { %>
@@ -57,17 +60,18 @@
5760
<% if (show_column('connections', 'client')) { %>
5861
<th><%= fmt_sort('Client', 'properties') %></th>
5962
<% } %>
60-
<% if (show_column('connections', 'from_client') && !disable_stats) { %>
63+
<% if (show_column('connections', 'from_client')) { %>
6164
<th><%= fmt_sort('From client', 'recv_oct_details.rate') %></th>
6265
<% } %>
63-
<% if (show_column('connections', 'to_client') && !disable_stats) { %>
66+
<% if (show_column('connections', 'to_client')) { %>
6467
<th><%= fmt_sort('To client', 'send_oct_details.rate') %></th>
6568
<% } %>
6669
<% if (show_column('connections', 'heartbeat')) { %>
6770
<th><%= fmt_sort('Heartbeat', 'timeout') %></th>
6871
<% } %>
6972
<% if (show_column('connections', 'connected_at')) { %>
7073
<th><%= fmt_sort('Connected at', 'connected_at') %></th>
74+
<% } %>
7175
<% } %>
7276
</tr>
7377
</thead>
@@ -103,7 +107,8 @@
103107
<% if (show_column('connections', 'user')) { %>
104108
<td class="c"><%= fmt_string(connection.user) %></td>
105109
<% } %>
106-
<% if (show_column('connections', 'state') && !disable_stats) { %>
110+
<% if (!disable_stats) { %>
111+
<% if (show_column('connections', 'state')) { %>
107112
<td><%= fmt_object_state(connection) %></td>
108113
<% } %>
109114
<% if (show_column('connections', 'ssl')) { %>
@@ -124,7 +129,7 @@
124129
<% if (show_column('connections', 'protocol')) { %>
125130
<td class="c"><%= connection.protocol %></td>
126131
<% } %>
127-
<% if (show_column('connections', 'channels') && !disable_stats) { %>
132+
<% if (show_column('connections', 'channels')) { %>
128133
<td class="r"><%= fmt_string(connection.channels, '') %></td>
129134
<% } %>
130135
<% if (show_column('connections', 'channel_max')) { %>
@@ -139,10 +144,10 @@
139144
<% if (show_column('connections', 'client')) { %>
140145
<td><%= fmt_client_name(connection.client_properties) %></td>
141146
<% } %>
142-
<% if (show_column('connections', 'from_client') && !disable_stats) { %>
147+
<% if (show_column('connections', 'from_client')) { %>
143148
<td><%= fmt_detail_rate_bytes(connection, 'recv_oct') %></td>
144149
<% } %>
145-
<% if (show_column('connections', 'to_client') && !disable_stats) { %>
150+
<% if (show_column('connections', 'to_client')) { %>
146151
<td><%= fmt_detail_rate_bytes(connection, 'send_oct') %></td>
147152
<% } %>
148153
<% if (show_column('connections', 'heartbeat')) { %>
@@ -151,6 +156,7 @@
151156
<% if (show_column('connections', 'connected_at')) { %>
152157
<td><%= fmt_timestamp_mini(connection.connected_at) %></td>
153158
<% } %>
159+
<% } %>
154160
</tr>
155161
<% } %>
156162
</tbody>

deps/rabbitmq_management/src/rabbit_mgmt_db.erl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
get_channel/2, get_connection/2,
2424
get_all_channels/1, get_all_connections/1,
2525
get_all_consumers/0, get_all_consumers/1,
26-
get_overview/2, get_overview/1,
27-
get_all_connections/0, get_connection/1]).
26+
get_overview/2, get_overview/1]).
2827

2928
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
3029
code_change/3, handle_pre_hibernate/1,
@@ -190,11 +189,6 @@ get_connection(Name, Ranges) ->
190189
end
191190
end).
192191

193-
get_connection(Name) ->
194-
submit(fun(_Interval) ->
195-
created_stats_delegated(Name, connection_created_stats)
196-
end).
197-
198192
get_all_channels(?NO_RANGES = Ranges) ->
199193
submit_cached(channels,
200194
fun(Interval) ->
@@ -219,11 +213,6 @@ get_all_connections(Ranges) ->
219213
connection_stats(Ranges, Chans, Interval)
220214
end).
221215

222-
get_all_connections() ->
223-
submit(fun(_) ->
224-
created_stats_delegated(connection_created_stats)
225-
end).
226-
227216
get_all_consumers() -> get_all_consumers(all).
228217
get_all_consumers(VHosts) ->
229218
submit(fun(_Interval) -> consumers_stats(VHosts) end).

deps/rabbitmq_management/src/rabbit_mgmt_wm_connection.erl

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,16 @@ resource_exists(ReqData, Context) ->
3535
end.
3636

3737
to_json(ReqData, Context) ->
38-
ConnStats =
39-
case rabbit_mgmt_util:disable_stats(ReqData) of
40-
false ->
41-
conn_stats(ReqData);
42-
true ->
43-
case rabbit_mgmt_db:get_connection(
44-
rabbit_mgmt_util:id(connection, ReqData)) of
45-
not_found ->
46-
%% IMPORTANT: connection_created_stats is empty when
47-
%% the metrics collector is disabled. Fall back to
48-
%% the tracked-connection record.
49-
conn(ReqData);
50-
Stats ->
51-
Stats
52-
end
53-
end,
54-
ConnStatsWithoutPids = rabbit_mgmt_format:strip_pids(ConnStats),
55-
ReplyData = maps:from_list(ConnStatsWithoutPids),
56-
rabbit_mgmt_util:reply(ReplyData, ReqData, Context).
38+
case rabbit_mgmt_util:disable_stats(ReqData) of
39+
false ->
40+
ConnStats = conn_stats(ReqData),
41+
ConnStatsWithoutPids = rabbit_mgmt_format:strip_pids(ConnStats),
42+
ReplyData = maps:from_list(ConnStatsWithoutPids),
43+
rabbit_mgmt_util:reply(ReplyData, ReqData, Context);
44+
true ->
45+
ReplyData = [{name, rabbit_mgmt_util:id(connection, ReqData)}],
46+
rabbit_mgmt_util:reply(ReplyData, ReqData, Context)
47+
end.
5748

5849
delete_resource(ReqData, Context) ->
5950
case conn(ReqData) of

deps/rabbitmq_management/src/rabbit_mgmt_wm_connections.erl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ do_connections_query(ReqData, Context) ->
4848
false ->
4949
augmented(ReqData, Context);
5050
true ->
51-
case rabbit_mgmt_agent_config:is_metrics_collector_enabled() of
52-
true ->
53-
rabbit_mgmt_util:filter_conn_ch_list(
54-
rabbit_mgmt_db:get_all_connections(), ReqData, Context);
55-
false ->
56-
%% IMPORTANT: connection_created_stats is empty when the
57-
%% metrics collector is disabled. Fall back to the
58-
%% tracked-connection list.
59-
rabbit_mgmt_util:filter_tracked_conn_list(
60-
rabbit_connection_tracking:list(), ReqData, Context)
61-
end
51+
rabbit_mgmt_util:filter_tracked_conn_list(rabbit_connection_tracking:list(),
52+
ReqData, Context)
6253
end.

deps/rabbitmq_management/test/rabbit_mgmt_only_http_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ connections_test(Config) ->
317317
[LocalPort, amqp_port(Config)])),
318318
await_condition(fun() ->
319319
C = http_get(Config, Path, ?OK),
320-
maps:is_key(name, C) andalso maps:is_key(client_properties, C) andalso
320+
maps:size(C) =:= 1 andalso maps:is_key(name, C) andalso
321321
not maps:is_key(recv_oct_details, C)
322322
end),
323323
http_delete(Config, Path, {group, '2xx'}),

0 commit comments

Comments
 (0)