@@ -72,7 +72,8 @@ groups() ->
72
72
vhost_status_metric ,
73
73
exchange_bindings_metric ,
74
74
exchange_names_metric ,
75
- stream_pub_sub_metrics
75
+ stream_pub_sub_metrics ,
76
+ raft_metrics_per_object_test
76
77
]},
77
78
{special_chars , [], [core_metrics_special_chars ]},
78
79
{authentication , [], [basic_auth ]}
@@ -158,6 +159,12 @@ init_per_group(detailed_metrics, Config0) ->
158
159
Q <- [ <<" queue-with-messages" >>, <<" queue-with-consumer" >> ]
159
160
],
160
161
162
+ amqp_channel :call (DefaultCh ,
163
+ # 'queue.declare' {queue = <<" a_quorum_queue" >>,
164
+ durable = true ,
165
+ arguments = [{<<" x-queue-type" >>, longstr , <<" quorum" >>}]
166
+ }),
167
+
161
168
DefaultConsumer = sleeping_consumer (),
162
169
# 'basic.consume_ok' {consumer_tag = DefaultCTag } =
163
170
amqp_channel :subscribe (DefaultCh , # 'basic.consume' {queue = <<" default-queue-with-consumer" >>}, DefaultConsumer ),
@@ -400,7 +407,14 @@ aggregated_metrics_test(Config) ->
400
407
? assertEqual (match , re :run (Body , " ^rabbitmq_erlang_uptime_seconds " , [{capture , none }, multiline ])),
401
408
? assertEqual (match , re :run (Body , " ^rabbitmq_io_read_time_seconds_total " , [{capture , none }, multiline ])),
402
409
% % 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 ])).
404
418
405
419
endpoint_per_object_metrics (Config ) ->
406
420
per_object_metrics_test (Config , " /metrics/per-object" ).
@@ -438,7 +452,8 @@ per_object_metrics_test(Config, Path) ->
438
452
? assertEqual (match , re :run (Body , " ^rabbitmq_io_read_time_seconds_total " , [{capture , none }, multiline ])),
439
453
? assertEqual (match , re :run (Body , " ^rabbitmq_raft_commit_latency_seconds{" , [{capture , none }, multiline ])),
440
454
% % 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 ])).
442
457
443
458
memory_breakdown_metrics_test (Config ) ->
444
459
{_Headers , Body } = http_get_with_pal (Config , " /metrics/memory-breakdown" , [], 200 ),
@@ -552,7 +567,8 @@ queue_consumer_count_all_vhosts_per_object_test(Config) ->
552
567
#{queue => " vhost-2-queue-with-consumer" ,vhost => " vhost-2" } => [1 ],
553
568
#{queue => " vhost-2-queue-with-messages" ,vhost => " vhost-2" } => [0 ],
554
569
#{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 ]},
556
572
557
573
rabbitmq_detailed_queue_info =>
558
574
#{#{queue => " default-queue-with-consumer" ,
@@ -578,7 +594,10 @@ queue_consumer_count_all_vhosts_per_object_test(Config) ->
578
594
#{queue => " vhost-2-queue-with-messages" ,
579
595
vhost => " vhost-2" ,
580
596
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 ]}
582
601
},
583
602
584
603
% % No vhost given, all should be returned
@@ -596,7 +615,8 @@ queue_coarse_metrics_per_object_test(Config) ->
596
615
Expected2 = #{#{queue => " vhost-2-queue-with-consumer" , vhost => " vhost-2" } => [11 ],
597
616
#{queue => " vhost-2-queue-with-messages" , vhost => " vhost-2" } => [11 ]},
598
617
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 ]},
600
620
601
621
{_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?vhost=vhost-1&family=queue_coarse_metrics" , [], 200 ),
602
622
? assertEqual (Expected1 ,
@@ -704,7 +724,8 @@ queue_metrics_per_object_test(Config) ->
704
724
Expected2 = #{#{queue => " vhost-2-queue-with-consumer" , vhost => " vhost-2" } => [11 ],
705
725
#{queue => " vhost-2-queue-with-messages" , vhost => " vhost-2" } => [1 ]},
706
726
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 ]},
708
729
{_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?vhost=vhost-1&family=queue_metrics" , [], 200 ),
709
730
? assertEqual (Expected1 ,
710
731
map_get (rabbitmq_detailed_queue_messages_ram , parse_response (Body1 ))),
@@ -835,6 +856,21 @@ core_metrics_special_chars(Config) ->
835
856
maps :to_list (LabelValue3 )),
836
857
ok .
837
858
859
+ raft_metrics_per_object_test (Config ) ->
860
+ Expected1 = #{#{module => " rabbit_khepri" , ra_system => " coordination" } => [" 0.0" ],
861
+ #{module => " rabbit_stream_coordinator" , ra_system => " coordination" } => [" 0.0" ]},
862
+ Expected2 = Expected1 #{#{queue => " a_quorum_queue" , vhost => " /" } => [" 0.0" ]},
863
+
864
+ {_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?family=raft_metrics&vhost=foo" , [], 200 ),
865
+ ? assertEqual (Expected1 ,
866
+ map_get (rabbitmq_raft_detailed_num_segments , parse_response (Body1 ))),
867
+
868
+ {_ , Body2 } = http_get_with_pal (Config , " /metrics/detailed?family=raft_metrics&vhost=/" , [], 200 ),
869
+ ? assertEqual (Expected2 ,
870
+ map_get (rabbitmq_raft_detailed_num_segments , parse_response (Body2 ))),
871
+
872
+ ok .
873
+
838
874
basic_auth (Config ) ->
839
875
http_get (Config , [{" accept-encoding" , " deflate" }], 401 ),
840
876
AuthHeader = rabbit_mgmt_test_util :auth_header (" guest" , " guest" ),
0 commit comments