4949 info :: info (),
5050 blocked_status = running :: blocked_status (),
5151 blocked_at :: integer () | undefined ,
52+ metrics :: #{remaining := rabbit_types :option (non_neg_integer ()) | unlimited ,
53+ ramaining_unacked := rabbit_types :option (non_neg_integer ()),
54+ pending := rabbit_types :option (non_neg_integer ()),
55+ forwarded := rabbit_types :option (non_neg_integer ())
56+ },
57+
5258 timestamp :: calendar :datetime ()}).
5359
5460start_link () ->
@@ -112,6 +118,7 @@ handle_call(status, _From, State) ->
112118 {reply , [{Entry # entry .name ,
113119 Entry # entry .type ,
114120 blocked_status_to_info (Entry ),
121+ Entry # entry .metrics ,
115122 Entry # entry .timestamp }
116123 || Entry <- Entries ], State };
117124
@@ -120,6 +127,7 @@ handle_call({lookup, Name}, _From, State) ->
120127 [Entry ] -> [{name , Name },
121128 {type , Entry # entry .type },
122129 {info , blocked_status_to_info (Entry )},
130+ {metrics , Entry # entry .metrics },
123131 {timestamp , Entry # entry .timestamp }];
124132 [] -> not_found
125133 end ,
@@ -141,6 +149,18 @@ handle_cast({report, Name, Type, Info, Timestamp}, State) ->
141149 split_name (Name ) ++ split_status (Info )),
142150 {noreply , State };
143151
152+ handle_cast ({report_blocked_status , Name , {Status , Metrics }, Timestamp }, State ) ->
153+ case Status of
154+ flow ->
155+ true = ets :update_element (? ETS_NAME , Name , [{# entry .blocked_status , flow },
156+ {# entry .metrics , Metrics },
157+ {# entry .blocked_at , Timestamp }]);
158+ _ ->
159+ true = ets :update_element (? ETS_NAME , Name , [{# entry .blocked_status , Status },
160+ {# entry .metrics , Metrics }])
161+ end ,
162+ {noreply , State };
163+ % % used in tests
144164handle_cast ({report_blocked_status , Name , Status , Timestamp }, State ) ->
145165 case Status of
146166 flow ->
@@ -178,22 +198,22 @@ code_change(_OldVsn, State, _Extra) ->
178198inject_node_info (Node , Shovels ) ->
179199 lists :map (
180200 % % starting
181- fun ({Name , Type , State , Timestamp }) when is_atom (State ) ->
201+ fun ({Name , Type , State , Metrics , Timestamp }) when is_atom (State ) ->
182202 Opts = [{node , Node }],
183- {Name , Type , {State , Opts }, Timestamp };
203+ {Name , Type , {State , Opts }, Metrics , Timestamp };
184204 % % terminated
185- ({Name , Type , {terminated , Reason }, Timestamp }) ->
186- {Name , Type , {terminated , Reason }, Timestamp };
205+ ({Name , Type , {terminated , Reason }, Metrics , Timestamp }) ->
206+ {Name , Type , {terminated , Reason }, Metrics , Timestamp };
187207 % % running
188- ({Name , Type , {State , Opts }, Timestamp }) ->
208+ ({Name , Type , {State , Opts }, Metrics , Timestamp }) ->
189209 Opts1 = Opts ++ [{node , Node }],
190- {Name , Type , {State , Opts1 }, Timestamp }
210+ {Name , Type , {State , Opts1 }, Metrics , Timestamp }
191211 end , Shovels ).
192212
193213-spec find_matching_shovel (rabbit_types :vhost (), binary (), [status_tuple ()]) -> status_tuple () | undefined .
194214find_matching_shovel (VHost , Name , Shovels ) ->
195215 case lists :filter (
196- fun ({{V , S }, _Kind , _Status , _ }) ->
216+ fun ({{V , S }, _Kind , _Status , _Metrics , _ }) ->
197217 VHost =:= V andalso Name =:= S
198218 end , Shovels ) of
199219 [] -> undefined ;
0 commit comments