Skip to content

Commit ac653d7

Browse files
committed
New metrics require a new macro on collector
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.
1 parent b5fb5c4 commit ac653d7

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,8 @@
214214
]}
215215
]).
216216

217-
%% Metrics that can be only requested through `/metrics/detailed`
218-
-define(METRICS_CLUSTER,[
219-
{vhost_status, [
220-
{2, undefined, vhost_status, gauge, "Whether a given vhost is running"}
221-
]},
222-
{exchange_bindings, [
223-
{2, undefined, exchange_bindings, gauge, "Number of bindings for an exchange. This value is cluster-wide."}
224-
]},
225-
{exchange_names, [
226-
{2, undefined, exchange_name, gauge, "Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings`"}
227-
]},
217+
%% Non aggregable detailed metrics
218+
-define(METRICS_RAW_NON_AGGREGABLE, [
228219
{queue_exchange_metrics, [
229220
{2, undefined, queue_exchange_messages_published_total, counter, "Total number of messages published into a queue through an exchange"}
230221
]},
@@ -242,7 +233,21 @@
242233
{6, undefined, queue_messages_redelivered_total, counter, "Total number of messages redelivered from a queue to consumers"},
243234
{7, undefined, queue_messages_acked_total, counter, "Total number of messages acknowledged by consumers on a queue"},
244235
{8, undefined, queue_get_empty_total, counter, "Total number of times basic.get operations fetched no message on a queue"}
245-
]}]).
236+
]}
237+
]).
238+
239+
%% Metrics that can be only requested through `/metrics/detailed`
240+
-define(METRICS_CLUSTER,[
241+
{vhost_status, [
242+
{2, undefined, vhost_status, gauge, "Whether a given vhost is running"}
243+
]},
244+
{exchange_bindings, [
245+
{2, undefined, exchange_bindings, gauge, "Number of bindings for an exchange. This value is cluster-wide."}
246+
]},
247+
{exchange_names, [
248+
{2, undefined, exchange_name, gauge, "Enumerates exchanges without any additional info. This value is cluster-wide. A cheaper alternative to `exchange_bindings`"}
249+
]}
250+
]).
246251

247252
-define(TOTALS, [
248253
%% ordering differs from metrics above, refer to list comprehension
@@ -263,6 +268,7 @@ deregister_cleanup(_) -> ok.
263268

264269
collect_mf('detailed', Callback) ->
265270
collect(true, ?DETAILED_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_RAW), Callback),
271+
collect(true, ?DETAILED_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_RAW_NON_AGGREGABLE), Callback),
266272
collect(true, ?CLUSTER_METRIC_NAME_PREFIX, vhosts_filter_from_pdict(), enabled_mfs_from_pdict(?METRICS_CLUSTER), Callback),
267273
%% identity is here to enable filtering on a cluster name (as already happens in existing dashboards)
268274
emit_identity_info(Callback),

deps/rabbitmq_prometheus/test/rabbit_prometheus_http_SUITE.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ groups() ->
6161
queue_exchange_metrics_per_object_test,
6262
queue_metrics_per_object_test,
6363
queue_consumer_count_and_queue_metrics_mutually_exclusive_test,
64+
exchange_metrics_per_object_test,
6465
vhost_status_metric,
6566
exchange_bindings_metric,
6667
exchange_names_metric
@@ -304,7 +305,16 @@ end_per_group_(Config) ->
304305
inets:stop(),
305306
rabbit_ct_helpers:run_teardown_steps(Config, rabbit_ct_client_helpers:teardown_steps()
306307
++ rabbit_ct_broker_helpers:teardown_steps()).
307-
308+
init_per_testcase(Testcase, Config)
309+
when Testcase =:= queue_counter_metrics_per_object_test;
310+
Testcase =:= queue_exchange_metrics_per_object_test ->
311+
case rabbit_ct_helpers:is_mixed_versions() of
312+
false ->
313+
rabbit_ct_helpers:testcase_started(Config, Testcase);
314+
true ->
315+
%% skip the test in mixed version mode
316+
{skip, "Should not run in mixed version environments"}
317+
end;
308318
init_per_testcase(Testcase, Config) ->
309319
rabbit_ct_helpers:testcase_started(Config, Testcase).
310320

0 commit comments

Comments
 (0)