Skip to content

Commit

Permalink
wip: add missing exchange_metrics to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisSotoLopez committed Jul 12, 2024
1 parent b5fb5c4 commit e5961ad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,6 @@

{channel_queue_exchange_metrics, [
{2, undefined, queue_messages_published_total, counter, "Total number of messages published into a queue through a exchange on a channel"}
]}
]).

%% Metrics that can be only requested through `/metrics/detailed`
-define(METRICS_CLUSTER,[
{vhost_status, [
{2, undefined, vhost_status, gauge, "Whether a given vhost is running"}
]},
{exchange_bindings, [
{2, undefined, exchange_bindings, gauge, "Number of bindings for an exchange. This value is cluster-wide."}
]},
{exchange_names, [
{2, undefined, exchange_name, gauge, "Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings`"}
]},
{queue_exchange_metrics, [
{2, undefined, queue_exchange_messages_published_total, counter, "Total number of messages published into a queue through an exchange"}
Expand All @@ -244,6 +231,19 @@
{8, undefined, queue_get_empty_total, counter, "Total number of times basic.get operations fetched no message on a queue"}
]}]).

%% Metrics that can be only requested through `/metrics/detailed`
-define(METRICS_CLUSTER,[
{vhost_status, [
{2, undefined, vhost_status, gauge, "Whether a given vhost is running"}
]},
{exchange_bindings, [
{2, undefined, exchange_bindings, gauge, "Number of bindings for an exchange. This value is cluster-wide."}
]},
{exchange_names, [
{2, undefined, exchange_name, gauge, "Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings`"}
]}
]).

-define(TOTALS, [
%% ordering differs from metrics above, refer to list comprehension
{connection_created, connections, gauge, "Connections currently open"},
Expand Down
17 changes: 14 additions & 3 deletions deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ groups() ->
queue_exchange_metrics_per_object_test,
queue_metrics_per_object_test,
queue_consumer_count_and_queue_metrics_mutually_exclusive_test,
exchange_metrics_per_object_test,
vhost_status_metric,
exchange_bindings_metric,
exchange_names_metric
Expand Down Expand Up @@ -304,7 +305,17 @@ end_per_group_(Config) ->
inets:stop(),
rabbit_ct_helpers:run_teardown_steps(Config, rabbit_ct_client_helpers:teardown_steps()
++ rabbit_ct_broker_helpers:teardown_steps()).

init_per_testcase(Testcase, Config)
when Testcase =:= queue_counter_metrics_per_object_test;
Testcase =:= queue_exchange_metrics_per_object_test;
Testcase =:= exchange_metrics_per_object_test ->
case rabbit_ct_helpers:is_mixed_versions() of
false ->
rabbit_ct_helpers:testcase_started(Config, Testcase);
true ->
%% skip the test in mixed version mode
{skip, "Should not run in mixed version environments"}
end;
init_per_testcase(Testcase, Config) ->
rabbit_ct_helpers:testcase_started(Config, Testcase).

Expand Down Expand Up @@ -603,8 +614,8 @@ queue_exchange_metrics_per_object_test(Config) ->
ok.

exchange_metrics_per_object_test(Config) ->
Expected1 = #{#{queue => "vhost-1-queue-with-consumer", vhost => "vhost-1"} => [7]},

Expected1 = #{#{exchange => "vhost-1-queue-with-consumer-direct-exchange", vhost => "vhost-1"} => [7]},
{_, Body} = http_get_with_pal(Config,
"/metrics/detailed?vhost=vhost-1&family=exchange_metrics",
[], 200),
Expand Down

0 comments on commit e5961ad

Please sign in to comment.