|
14 | 14 |
|
15 | 15 | -export([start_link/0]). |
16 | 16 |
|
17 | | --export([report/3, |
| 17 | +-export([report/3, report/4, |
18 | 18 | report_blocked_status/2, |
19 | 19 | remove/1, |
20 | 20 | status/0, |
@@ -78,6 +78,12 @@ start_link() -> |
78 | 78 | report(Name, Type, Info) -> |
79 | 79 | gen_server:cast(?SERVER, {report, Name, Type, Info, calendar:local_time()}). |
80 | 80 |
|
| 81 | +-spec report(name(), type(), info(), metrics()) -> ok. |
| 82 | +report(Name, Type, Info, Metrics) -> |
| 83 | + %% Initialise metrics for protocols that don't immediately generate a |
| 84 | + %% blocked status report. This happens with AMQP 1.0 |
| 85 | + gen_server:cast(?SERVER, {report, Name, Type, Info, Metrics, calendar:local_time()}). |
| 86 | + |
81 | 87 | -spec report_blocked_status(name(), {blocked_status(), metrics()} | blocked_status()) -> ok. |
82 | 88 | report_blocked_status(Name, Status) -> |
83 | 89 | gen_server:cast(?SERVER, {report_blocked_status, Name, Status, erlang:monotonic_time()}). |
@@ -164,6 +170,19 @@ handle_cast({report, Name, Type, Info, Timestamp}, State) -> |
164 | 170 | split_name(Name) ++ split_status(Info)), |
165 | 171 | {noreply, State}; |
166 | 172 |
|
| 173 | +handle_cast({report, Name, Type, Info, Metrics, Timestamp}, State) -> |
| 174 | + Entry = #entry{ |
| 175 | + name = Name, |
| 176 | + type = Type, |
| 177 | + info = Info, |
| 178 | + metrics = Metrics, |
| 179 | + timestamp = Timestamp |
| 180 | + }, |
| 181 | + true = ets:insert(?ETS_NAME, Entry), |
| 182 | + rabbit_event:notify(shovel_worker_status, |
| 183 | + split_name(Name) ++ split_status(Info)), |
| 184 | + {noreply, State}; |
| 185 | + |
167 | 186 | handle_cast({report_blocked_status, Name, {Status, Metrics}, Timestamp}, State) -> |
168 | 187 | case Status of |
169 | 188 | flow -> |
|
0 commit comments