Skip to content

Commit

Permalink
New metrics require a new macro on collector
Browse files Browse the repository at this point in the history
Previous commits include new metrics on the `CLUTER_METRICS` group,
since those ones do not get aggregated and are only shown on under
the `/metrics/detailed` endpoint. However that group of metrics
correspond to cluster-wide metrics (that's why they don't need to
get aggregated) and therefore the new metrics we are providing do
not perfectly fit in that group. A new macro/group is provided by
this commit.
  • Loading branch information
LoisSotoLopez committed Jul 12, 2024
1 parent b5fb5c4 commit ac653d7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,8 @@
]}
]).

%% 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`"}
]},
%% Non aggregable detailed metrics
-define(METRICS_RAW_NON_AGGREGABLE, [
{queue_exchange_metrics, [
{2, undefined, queue_exchange_messages_published_total, counter, "Total number of messages published into a queue through an exchange"}
]},
Expand All @@ -242,7 +233,21 @@
{6, undefined, queue_messages_redelivered_total, counter, "Total number of messages redelivered from a queue to consumers"},
{7, undefined, queue_messages_acked_total, counter, "Total number of messages acknowledged by consumers on a queue"},
{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
Expand All @@ -263,6 +268,7 @@ deregister_cleanup(_) -> ok.

collect_mf('detailed', Callback) ->
collect(true, ?DETAILED_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_RAW), Callback),
collect(true, ?DETAILED_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_RAW_NON_AGGREGABLE), Callback),
collect(true, ?CLUSTER_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_CLUSTER), Callback),
%% identity is here to enable filtering on a cluster name (as already happens in existing dashboards)
emit_identity_info(Callback),
Expand Down
12 changes: 11 additions & 1 deletion 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,16 @@ 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 ->
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

0 comments on commit ac653d7

Please sign in to comment.