66% %
77-module (rabbit_shovel_prometheus_collector ).
88
9+ -include_lib (" kernel/include/logger.hrl" ).
10+ -include_lib (" rabbit_common/include/logging.hrl" ).
11+
912-behaviour (prometheus_collector ).
1013
1114-export ([start /0 , stop /0 ]).
@@ -29,10 +32,15 @@ deregister_cleanup(_) -> ok.
2932
3033collect_mf (_Registry , Callback ) ->
3134 Status = rabbit_shovel_status :status (500 ),
32- {StaticStatusGroups , DynamicStatusGroups } = lists :foldl (fun ({_ ,static ,{S , _ }, _ , _ }, {SMap , DMap }) ->
33- {maps :update_with (S , fun (C ) -> C + 1 end , 1 , SMap ), DMap };
34- ({_ ,dynamic ,{S , _ }, _ , _ }, {SMap , DMap }) ->
35- {SMap , maps :update_with (S , fun (C ) -> C + 1 end , 1 , DMap )}
35+ % % Shovel status can be an atom or a tuple of {string(), proplists:proplist()}
36+ {StaticStatusGroups , DynamicStatusGroups } = lists :foldl (fun ({_ , static , S , _ , _ }, {SMap , DMap }) when is_atom (S ) ->
37+ {maps :update_with (S , fun (C ) -> C + 1 end , 1 , SMap ), DMap };
38+ ({_ , static , {S , _ }, _ , _ }, {SMap , DMap }) ->
39+ {maps :update_with (S , fun (C ) -> C + 1 end , 1 , SMap ), DMap };
40+ ({_ , dynamic , S , _ , _ }, {SMap , DMap }) when is_atom (S ) ->
41+ {SMap , maps :update_with (S , fun (C ) -> C + 1 end , 1 , DMap )};
42+ ({_ , dynamic , {S , _ }, _ , _ }, {SMap , DMap }) ->
43+ {SMap , maps :update_with (S , fun (C ) -> C + 1 end , 1 , DMap )}
3644 end , {#{}, #{}}, Status ),
3745
3846 Metrics = [{rabbitmq_shovel_dynamic , gauge , " Number of dynamic shovels" ,
@@ -47,5 +55,5 @@ add_metric_family({Name, Type, Help, Metrics}, Callback) ->
4755 Callback (create_mf (Name , Help , Type , Metrics )).
4856
4957% %====================================================================
50- % % Private Parts
58+ % % Implementation
5159% %====================================================================
0 commit comments