6
6
% %
7
7
-module (rabbit_shovel_prometheus_collector ).
8
8
9
+ -include_lib (" kernel/include/logger.hrl" ).
10
+ -include_lib (" rabbit_common/include/logging.hrl" ).
11
+
9
12
-behaviour (prometheus_collector ).
10
13
11
14
-export ([start /0 , stop /0 ]).
@@ -29,10 +32,15 @@ deregister_cleanup(_) -> ok.
29
32
30
33
collect_mf (_Registry , Callback ) ->
31
34
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 )}
36
44
end , {#{}, #{}}, Status ),
37
45
38
46
Metrics = [{rabbitmq_shovel_dynamic , gauge , " Number of dynamic shovels" ,
@@ -47,5 +55,5 @@ add_metric_family({Name, Type, Help, Metrics}, Callback) ->
47
55
Callback (create_mf (Name , Help , Type , Metrics )).
48
56
49
57
% %====================================================================
50
- % % Private Parts
58
+ % % Implementation
51
59
% %====================================================================
0 commit comments