Commit
count.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,8 @@ out(NameOrPid, Num) when (is_atom(NameOrPid) orelse is_pid(NameOrPid)) andalso i | |
Packet | ||
end. | ||
|
||
-spec info(atom()|pid()) -> | ||
{pos_integer(), pos_integer()}. | ||
info(NameOrPid) when is_atom(NameOrPid); is_pid(NameOrPid) -> | ||
gen_server:call(NameOrPid, info, ?TIMEOUT). | ||
|
||
|
@@ -174,8 +176,15 @@ handle_call(_Msg, _From, State) -> | |
%% @hidden | ||
%%-------------------------------------------------------------------- | ||
handle_cast({in, _Packet}, #state{dict=Dict, dropped_stat_key=StatKey, length=Length, max_length=MaxLength, num_dropped=NumDropped}=State) when Length >= MaxLength -> | ||
logplex_stats:incr(StatKey), | ||
logplex_realtime:incr(StatKey), | ||
RedisUrl = case dict:find(redis_url, Dict) of | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
omarkj
Author
Contributor
|
||
{ok, Value} -> | ||
Value; | ||
undefined -> | ||
undefined | ||
end, | ||
logplex_stats:incr(#queue_stat{key=StatKey, | ||
redis_url=RedisUrl}), | ||
case dict:find(producer_callback, Dict) of | ||
{ok, Fun} -> Fun(self(), stop_accepting); | ||
error -> ok | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,8 @@ incr(Key) -> | |
incr(Key, 1). | ||
|
||
-spec incr(#drain_stat{} | #channel_stat{} | #logplex_stat{} | | ||
list() | atom(), | ||
integer()) -> any(). | ||
#queue_stat{} | list() | atom(), integer()) -> | ||
any(). | ||
incr(Key, Incr) when is_integer(Incr) -> | ||
try ets:update_counter(?MODULE, Key, Incr) | ||
catch error:badarg -> | ||
|
@@ -163,6 +163,10 @@ log_stat(UnixTS, #logplex_stat{module=Mod, key=K}, Val) -> | |
io:format("m=logplex_stats ts=~p system module=~p ~200p=~p~n", | ||
[UnixTS, Mod, K, Val]); | ||
|
||
log_stat(UnixTS, #queue_stat{redis_url=RedisUrl, key=Key}, Val) -> | ||
io:format("m=logplex_stats ts=~p redis_url=~p ~p=~p~n", | ||
This comment has been minimized.
Sorry, something went wrong.
ferd
Contributor
|
||
[UnixTS, RedisUrl, Key, Val]); | ||
|
||
log_stat(UnixTS, {Class, Key}, Val) -> | ||
io:format("m=logplex_stats ts=~p freeform class=~p key=~p count=~p~n", | ||
[UnixTS, Class, Key, Val]); | ||
|
How big is the dict, and how often are we calling this? If this is overflow control and requires many lookups on a large dict, this can be a bit risky.