Skip to content

Commit 4cbbd61

Browse files
Merge pull request #15035 from rabbitmq/mergify/bp/v4.2.x/pr-15028
Prometheus endpoint: faster scraping (backport #15028)
2 parents fd04196 + 16c26ad commit 4cbbd61

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

deps/rabbitmq_prometheus/src/collectors/prometheus_rabbitmq_core_metrics_collector.erl

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,11 +527,30 @@ has_value_p(_) ->
527527
true.
528528

529529
collect_metrics(_, {Type, Fun, Items}) ->
530+
erlang:process_flag(min_heap_size, 46422 * 32),
531+
erlang:process_flag(min_bin_vheap_size, 46422 * 32),
530532
[metric(Type, labels(Item), V) || {Item, V} <- [{Item, Fun(Item)} || Item <- Items], has_value_p(V)].
531533

532534
labels(Item) ->
533535
label(element(1, Item)).
534536

537+
label(channel_exchange_metrics) -> <<>>;
538+
label(channel_metrics) -> <<>>;
539+
label(channel_process_metrics) -> <<>>;
540+
label(channel_queue_exchange_metrics) -> <<>>;
541+
label(channel_queue_metrics) -> <<>>;
542+
label(connection_coarse_metrics) -> <<>>;
543+
label(connection_metrics) -> <<>>;
544+
label(exchange_metrics) -> <<>>;
545+
label(queue_coarse_metrics) -> <<>>;
546+
label(queue_delivery_metrics) -> <<>>;
547+
label(queue_exchange_metrics) -> <<>>;
548+
label(queue_metrics) -> <<>>;
549+
label(stream_consumer_metrics) -> <<>>;
550+
label(amqp091) -> <<"protocol=\"amqp091\"">>;
551+
label(amqp10) -> <<"protocol=\"amqp10\"">>;
552+
label(mqtt) -> <<"protocol=\"mqtt\"">>;
553+
label(http) -> <<"protocol=\"http\"">>;
535554
label(L) when is_binary(L) ->
536555
L;
537556
label(M) when is_map(M) ->
@@ -577,14 +596,7 @@ label({I1, I2}) ->
577596
end;
578597
label(P) when is_pid(P) ->
579598
<<"channel=\"", (iolist_to_binary(pid_to_list(P)))/binary, "\"">>;
580-
label(A) when is_atom(A) ->
581-
case is_protocol(A) of
582-
true -> <<"protocol=\"", (atom_to_binary(A, utf8))/binary, "\"">>;
583-
false -> <<>>
584-
end.
585-
586-
is_protocol(P) ->
587-
lists:member(P, [amqp091, amqp10, mqtt, http]).
599+
label(_) -> <<>>.
588600

589601
metric(counter, Labels, Value) ->
590602
emit_counter_metric_if_defined(Labels, Value);

0 commit comments

Comments
 (0)