@@ -72,7 +72,8 @@ groups() ->
7272 vhost_status_metric ,
7373 exchange_bindings_metric ,
7474 exchange_names_metric ,
75- stream_pub_sub_metrics
75+ stream_pub_sub_metrics ,
76+ raft_detailed_metrics_test
7677 ]},
7778 {special_chars , [], [core_metrics_special_chars ]},
7879 {authentication , [], [basic_auth ]}
@@ -158,6 +159,12 @@ init_per_group(detailed_metrics, Config0) ->
158159 Q <- [ <<" queue-with-messages" >>, <<" queue-with-consumer" >> ]
159160 ],
160161
162+ amqp_channel :call (DefaultCh ,
163+ # 'queue.declare' {queue = <<" a_quorum_queue" >>,
164+ durable = true ,
165+ arguments = [{<<" x-queue-type" >>, longstr , <<" quorum" >>}]
166+ }),
167+
161168 DefaultConsumer = sleeping_consumer (),
162169 # 'basic.consume_ok' {consumer_tag = DefaultCTag } =
163170 amqp_channel :subscribe (DefaultCh , # 'basic.consume' {queue = <<" default-queue-with-consumer" >>}, DefaultConsumer ),
@@ -400,7 +407,14 @@ aggregated_metrics_test(Config) ->
400407 ? assertEqual (match , re :run (Body , " ^rabbitmq_erlang_uptime_seconds " , [{capture , none }, multiline ])),
401408 ? assertEqual (match , re :run (Body , " ^rabbitmq_io_read_time_seconds_total " , [{capture , none }, multiline ])),
402409 % % Check the first TOTALS metric value
403- ? assertEqual (match , re :run (Body , " ^rabbitmq_connections " , [{capture , none }, multiline ])).
410+ ? assertEqual (match , re :run (Body , " ^rabbitmq_connections " , [{capture , none }, multiline ])),
411+ ? assertEqual (nomatch , re :run (Body , " ^rabbitmq_raft_commit_latency_seconds" , [{capture , none }, multiline ])),
412+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_bytes_written.*ra_log_segment_writer" , [{capture , none }, multiline ])),
413+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_bytes_written.*ra_log_wal" , [{capture , none }, multiline ])),
414+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_entries{" , [{capture , none }, multiline ])),
415+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_mem_tables{" , [{capture , none }, multiline ])),
416+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_segments{" , [{capture , none }, multiline ])),
417+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_wal_files{" , [{capture , none }, multiline ])).
404418
405419endpoint_per_object_metrics (Config ) ->
406420 per_object_metrics_test (Config , " /metrics/per-object" ).
@@ -438,7 +452,8 @@ per_object_metrics_test(Config, Path) ->
438452 ? assertEqual (match , re :run (Body , " ^rabbitmq_io_read_time_seconds_total " , [{capture , none }, multiline ])),
439453 ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_commit_latency_seconds{" , [{capture , none }, multiline ])),
440454 % % Check the first TOTALS metric value
441- ? assertEqual (match , re :run (Body , " ^rabbitmq_connections " , [{capture , none }, multiline ])).
455+ ? assertEqual (match , re :run (Body , " ^rabbitmq_connections " , [{capture , none }, multiline ])),
456+ ? assertEqual (match , re :run (Body , " ^rabbitmq_raft_num_segments{" , [{capture , none }, multiline ])).
442457
443458memory_breakdown_metrics_test (Config ) ->
444459 {_Headers , Body } = http_get_with_pal (Config , " /metrics/memory-breakdown" , [], 200 ),
@@ -552,7 +567,8 @@ queue_consumer_count_all_vhosts_per_object_test(Config) ->
552567 #{queue => " vhost-2-queue-with-consumer" ,vhost => " vhost-2" } => [1 ],
553568 #{queue => " vhost-2-queue-with-messages" ,vhost => " vhost-2" } => [0 ],
554569 #{queue => " default-queue-with-consumer" ,vhost => " /" } => [1 ],
555- #{queue => " default-queue-with-messages" ,vhost => " /" } => [0 ]},
570+ #{queue => " default-queue-with-messages" ,vhost => " /" } => [0 ],
571+ #{queue => " a_quorum_queue" ,vhost => " /" } => [0 ]},
556572
557573 rabbitmq_detailed_queue_info =>
558574 #{#{queue => " default-queue-with-consumer" ,
@@ -578,7 +594,10 @@ queue_consumer_count_all_vhosts_per_object_test(Config) ->
578594 #{queue => " vhost-2-queue-with-messages" ,
579595 vhost => " vhost-2" ,
580596 queue_type => " rabbit_classic_queue" ,
581- membership => " leader" } => [1 ]}
597+ membership => " leader" } => [1 ],
598+ #{membership => " leader" ,
599+ queue => " a_quorum_queue" ,vhost => " /" ,
600+ queue_type => " rabbit_quorum_queue" } => [1 ]}
582601 },
583602
584603 % % No vhost given, all should be returned
@@ -596,7 +615,8 @@ queue_coarse_metrics_per_object_test(Config) ->
596615 Expected2 = #{#{queue => " vhost-2-queue-with-consumer" , vhost => " vhost-2" } => [11 ],
597616 #{queue => " vhost-2-queue-with-messages" , vhost => " vhost-2" } => [11 ]},
598617 ExpectedD = #{#{queue => " default-queue-with-consumer" , vhost => " /" } => [3 ],
599- #{queue => " default-queue-with-messages" , vhost => " /" } => [3 ]},
618+ #{queue => " default-queue-with-messages" , vhost => " /" } => [3 ],
619+ #{queue => " a_quorum_queue" ,vhost => " /" } => [0 ]},
600620
601621 {_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?vhost=vhost-1&family=queue_coarse_metrics" , [], 200 ),
602622 ? assertEqual (Expected1 ,
@@ -704,7 +724,8 @@ queue_metrics_per_object_test(Config) ->
704724 Expected2 = #{#{queue => " vhost-2-queue-with-consumer" , vhost => " vhost-2" } => [11 ],
705725 #{queue => " vhost-2-queue-with-messages" , vhost => " vhost-2" } => [1 ]},
706726 ExpectedD = #{#{queue => " default-queue-with-consumer" , vhost => " /" } => [3 ],
707- #{queue => " default-queue-with-messages" , vhost => " /" } => [1 ]},
727+ #{queue => " default-queue-with-messages" , vhost => " /" } => [1 ],
728+ #{queue => " a_quorum_queue" ,vhost => " /" } => [0 ]},
708729 {_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?vhost=vhost-1&family=queue_metrics" , [], 200 ),
709730 ? assertEqual (Expected1 ,
710731 map_get (rabbitmq_detailed_queue_messages_ram , parse_response (Body1 ))),
@@ -835,6 +856,27 @@ core_metrics_special_chars(Config) ->
835856 maps :to_list (LabelValue3 )),
836857 ok .
837858
859+ raft_detailed_metrics_test (Config ) ->
860+ ComponentMetrics = #{#{module => " ra_log_wal" , ra_system => " coordination" } => [" 1.0" ],
861+ #{module => " ra_log_wal" , ra_system => " quorum_queues" } => [" 1.0" ]},
862+ QQMetrics = #{#{queue => " a_quorum_queue" , vhost => " /" } => [" 1.0" ]},
863+
864+ {_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?family=raft_metrics&vhost=foo" , [], 200 ),
865+ % % no queues in vhost foo, so no QQ metrics
866+ ? assertEqual (ComponentMetrics ,
867+ map_get (rabbitmq_raft_detailed_wal_files , parse_response (Body1 ))),
868+ ? assertEqual (undefined ,
869+ maps :get (rabbitmq_raft_detailed_term , parse_response (Body1 ), undefined )),
870+
871+ {_ , Body2 } = http_get_with_pal (Config , " /metrics/detailed?family=raft_metrics&vhost=/" , [], 200 ),
872+ % % there's a queue in vhost /
873+ ? assertEqual (ComponentMetrics ,
874+ map_get (rabbitmq_raft_detailed_wal_files , parse_response (Body2 ))),
875+ ? assertEqual (QQMetrics ,
876+ map_get (rabbitmq_raft_detailed_term , parse_response (Body2 ))),
877+
878+ ok .
879+
838880basic_auth (Config ) ->
839881 http_get (Config , [{" accept-encoding" , " deflate" }], 401 ),
840882 AuthHeader = rabbit_mgmt_test_util :auth_header (" guest" , " guest" ),
0 commit comments