Просмотр исходного кода

Merge pull request #475 from russagit/master

Fix check_hwm
pull/479/head
Mark Allen 6 лет назад
committed by GitHub
Родитель
Сommit
3d61650ae2
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: 4AEE18F83AFDEB23
2 измененных файлов: 14 добавлений и 3 удалений
  1. +5
    -0
      src/error_logger_lager_h.erl
  2. +9
    -3
      src/lager_util.erl

+ 5
- 0
src/error_logger_lager_h.erl Просмотреть файл

@ -624,6 +624,11 @@ no_silent_hwm_drops_test_() ->
[error_logger:error_msg("Foo ~p~n", [K]) || K <- lists:seq(1, 15)],
timer:sleep(1000),
lager_handler_watcher:pop_until("lager_error_logger_h dropped 10 messages in the last second that exceeded the limit of 5 messages/sec",
fun lists:flatten/1),
%and once again
[error_logger:error_msg("Foo1 ~p~n", [K]) || K <- lists:seq(1, 20)],
timer:sleep(1000),
lager_handler_watcher:pop_until("lager_error_logger_h dropped 16 messages in the last second that exceeded the limit of 5 messages/sec",
fun lists:flatten/1)
after
application:stop(lager),

+ 9
- 3
src/lager_util.erl Просмотреть файл

@ -501,9 +501,15 @@ check_hwm(Shaper = #lager_shaper{filter = Filter}, Event) ->
check_hwm(Shaper = #lager_shaper{hwm = undefined}) ->
{true, 0, Shaper};
check_hwm(Shaper = #lager_shaper{mps = Mps, hwm = Hwm}) when Mps < Hwm ->
%% haven't hit high water mark yet, just log it
{true, 0, Shaper#lager_shaper{mps=Mps+1, lasttime = os:timestamp()}};
check_hwm(Shaper = #lager_shaper{mps = Mps, hwm = Hwm, lasttime = Last}) when Mps < Hwm ->
{M, S, _} = Now = os:timestamp(),
case Last of
{M, S, _} ->
{true, 0, Shaper#lager_shaper{mps=Mps+1}};
_ ->
%different second - reset mps
{true, 0, Shaper#lager_shaper{mps=1, lasttime = Now}}
end;
check_hwm(Shaper = #lager_shaper{lasttime = Last, dropped = Drop}) ->
%% are we still in the same second?
{M, S, _} = Now = os:timestamp(),

Загрузка…
Отмена
Сохранить