Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compatibility code for management agent feature flags #7223

Merged
merged 1 commit into from
Feb 9, 2023
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
38 changes: 3 additions & 35 deletions deps/rabbitmq_management_agent/src/rabbit_mgmt_data.erl
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ lookup_smaller_sample(Table, Id) ->
[] ->
not_found;
[{_, Slide}] ->
Slide1 = exometer_slide:optimize(Slide),
maybe_convert_for_compatibility(Table, Slide1)
exometer_slide:optimize(Slide)
end.

-spec lookup_samples(atom(), any(), #range{}) -> maybe_slide().
Expand All @@ -366,8 +365,7 @@ lookup_samples(Table, Id, Range) ->
[] ->
not_found;
[{_, Slide}] ->
Slide1 = exometer_slide:optimize(Slide),
maybe_convert_for_compatibility(Table, Slide1)
exometer_slide:optimize(Slide)
end.

lookup_all(Table, Ids, SecondKey) ->
Expand All @@ -383,39 +381,9 @@ lookup_all(Table, Ids, SecondKey) ->
[] ->
not_found;
_ ->
Slide = exometer_slide:sum(Slides, empty(Table, 0)),
maybe_convert_for_compatibility(Table, Slide)
exometer_slide:sum(Slides, empty(Table, 0))
end.

maybe_convert_for_compatibility(Table, Slide)
when Table =:= channel_stats_fine_stats orelse
Table =:= channel_exchange_stats_fine_stats orelse
Table =:= vhost_stats_fine_stats ->
ConversionNeeded = rabbit_feature_flags:is_disabled(
drop_unroutable_metric),
case ConversionNeeded of
false ->
Slide;
true ->
%% drop_drop because the metric is named "drop_unroutable"
rabbit_mgmt_data_compat:drop_drop_unroutable_metric(Slide)
end;
maybe_convert_for_compatibility(Table, Slide)
when Table =:= channel_queue_stats_deliver_stats orelse
Table =:= channel_stats_deliver_stats orelse
Table =:= queue_stats_deliver_stats orelse
Table =:= vhost_stats_deliver_stats ->
ConversionNeeded = rabbit_feature_flags:is_disabled(
empty_basic_get_metric),
case ConversionNeeded of
false ->
Slide;
true ->
rabbit_mgmt_data_compat:drop_get_empty_queue_metric(Slide)
end;
maybe_convert_for_compatibility(_, Slide) ->
Slide.

get_table_keys(Table, Id0) ->
ets:select(Table, match_spec_keys(Id0)).

Expand Down
33 changes: 1 addition & 32 deletions deps/rabbitmq_management_agent/src/rabbit_mgmt_data_compat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
-module(rabbit_mgmt_data_compat).

-export([fill_get_empty_queue_metric/1,
drop_get_empty_queue_metric/1,
fill_consumer_active_fields/1,
fill_drop_unroutable_metric/1,
drop_drop_unroutable_metric/1]).
fill_drop_unroutable_metric/1]).

fill_get_empty_queue_metric(Slide) ->
exometer_slide:map(
Expand All @@ -26,21 +24,6 @@ fill_get_empty_queue_metric(Slide) ->
Value
end, Slide).

drop_get_empty_queue_metric(Slide) ->
exometer_slide:map(
fun
(Value) when is_tuple(Value) andalso size(Value) =:= 8 ->
%% We want to remove the last element, which is
%% the count of basic.get on empty queues.
list_to_tuple(
lists:sublist(
tuple_to_list(Value), size(Value) - 1));
(Value) when is_tuple(Value) andalso size(Value) =:= 7 ->
Value;
(Value) ->
Value
end, Slide).

fill_drop_unroutable_metric(Slide) ->
exometer_slide:map(
fun
Expand All @@ -54,20 +37,6 @@ fill_drop_unroutable_metric(Slide) ->
Value
end, Slide).

drop_drop_unroutable_metric(Slide) ->
exometer_slide:map(
fun
(Value) when is_tuple(Value) andalso size(Value) =:= 4 ->
%% Remove the last element.
list_to_tuple(
lists:sublist(
tuple_to_list(Value), size(Value) - 1));
(Value) when is_tuple(Value) andalso size(Value) =:= 3 ->
Value;
(Value) ->
Value
end, Slide).

fill_consumer_active_fields(ConsumersStatsList) ->
[case proplists:get_value(active, ConsumerStats) of
undefined ->
Expand Down
2 changes: 0 additions & 2 deletions deps/rabbitmq_management_agent/src/rabbit_mgmt_ff.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
-rabbit_feature_flag(
{empty_basic_get_metric,
#{desc => "Count AMQP `basic.get` on empty queues in stats",
%%TODO remove compatibility code
stability => required
}}).

-rabbit_feature_flag(
{drop_unroutable_metric,
#{desc => "Count unroutable publishes to be dropped in stats",
%%TODO remove compatibility code
stability => required
}}).
2 changes: 1 addition & 1 deletion deps/rabbitmq_mqtt/src/rabbit_mqtt_ff.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@

-spec track_client_id_in_ra() -> boolean().
track_client_id_in_ra() ->
not rabbit_feature_flags:is_enabled(delete_ra_cluster_mqtt_node).
rabbit_feature_flags:is_disabled(delete_ra_cluster_mqtt_node).