|
@ -7,8 +7,8 @@ |
|
|
-export([ |
|
|
-export([ |
|
|
start/0 |
|
|
start/0 |
|
|
, start/2 |
|
|
, start/2 |
|
|
, boot/1 |
|
|
|
|
|
, stop/1 |
|
|
, stop/1 |
|
|
|
|
|
, doStart/1 |
|
|
, start_handler/3 |
|
|
, start_handler/3 |
|
|
, configure_sink/2 |
|
|
, configure_sink/2 |
|
|
]). |
|
|
]). |
|
@ -21,14 +21,14 @@ start() -> |
|
|
start(_StartType, _StartArgs) -> |
|
|
start(_StartType, _StartArgs) -> |
|
|
{ok, Pid} = eRum_sup:start_link(), |
|
|
{ok, Pid} = eRum_sup:start_link(), |
|
|
SavedHandlers = boot(), |
|
|
SavedHandlers = boot(), |
|
|
_ = boot('__all_extra'), |
|
|
|
|
|
_ = boot('__traces'), |
|
|
|
|
|
|
|
|
_ = doStart('__all_extra'), |
|
|
|
|
|
_ = doStart('__traces'), |
|
|
clean_up_config_checks(), |
|
|
clean_up_config_checks(), |
|
|
{ok, Pid, SavedHandlers}. |
|
|
{ok, Pid, SavedHandlers}. |
|
|
|
|
|
|
|
|
boot() -> |
|
|
boot() -> |
|
|
%% Handle the default sink. |
|
|
%% Handle the default sink. |
|
|
determine_async_behavior(?RumDefSink, application:get_env(lager, async_threshold, undefined), application:get_env(lager, async_threshold_window, undefined)), |
|
|
|
|
|
|
|
|
tryStartAsyncer(?RumDefSink, rumUtil:get_env(?RumAppName, asyncThreshold, undefined), rumUtil:get_env(?RumAppName, asyncThresholdWindow, undefined)), |
|
|
|
|
|
|
|
|
_ = maybe_install_sink_killer(?RumDefSink, application:get_env(lager, killer_hwm, undefined), |
|
|
_ = maybe_install_sink_killer(?RumDefSink, application:get_env(lager, killer_hwm, undefined), |
|
|
application:get_env(lager, killer_reinstall_after, undefined)), |
|
|
application:get_env(lager, killer_reinstall_after, undefined)), |
|
@ -45,15 +45,15 @@ boot() -> |
|
|
|
|
|
|
|
|
SavedHandlers. |
|
|
SavedHandlers. |
|
|
|
|
|
|
|
|
boot('__traces') -> |
|
|
|
|
|
|
|
|
doStart('__traces') -> |
|
|
_ = rumUtil:trace_filter(none), |
|
|
_ = rumUtil:trace_filter(none), |
|
|
ok = add_configured_traces(); |
|
|
ok = add_configured_traces(); |
|
|
|
|
|
|
|
|
boot('__all_extra') -> |
|
|
|
|
|
|
|
|
doStart('__all_extra') -> |
|
|
configure_extra_sinks(application:get_env(lager, extra_sinks, [])); |
|
|
configure_extra_sinks(application:get_env(lager, extra_sinks, [])); |
|
|
|
|
|
|
|
|
boot(?RumDefSink) -> boot(); |
|
|
|
|
|
boot(Sink) -> |
|
|
|
|
|
|
|
|
doStart(?RumDefSink) -> boot(); |
|
|
|
|
|
doStart(Sink) -> |
|
|
AllSinksDef = application:get_env(lager, extra_sinks, []), |
|
|
AllSinksDef = application:get_env(lager, extra_sinks, []), |
|
|
boot_sink(Sink, lists:keyfind(Sink, 1, AllSinksDef)). |
|
|
boot_sink(Sink, lists:keyfind(Sink, 1, AllSinksDef)). |
|
|
|
|
|
|
|
@ -68,21 +68,21 @@ stop(Handlers) -> |
|
|
end, Handlers), |
|
|
end, Handlers), |
|
|
rumConfig:cleanup(). |
|
|
rumConfig:cleanup(). |
|
|
|
|
|
|
|
|
determine_async_behavior(_Sink, undefined, _Window) -> |
|
|
|
|
|
|
|
|
tryStartAsyncer(_Sink, undefined, _Window) -> |
|
|
ok; |
|
|
ok; |
|
|
determine_async_behavior(_Sink, Threshold, _Window) when not is_integer(Threshold) orelse Threshold < 0 -> |
|
|
|
|
|
error_logger:error_msg("Invalid value for 'async_threshold': ~p~n", [Threshold]), |
|
|
|
|
|
|
|
|
tryStartAsyncer(_Sink, Threshold, _Window) when not is_integer(Threshold) orelse Threshold < 0 -> |
|
|
|
|
|
error_logger:error_msg("Invalid value for 'asyncThreshold': ~p~n", [Threshold]), |
|
|
throw({error, bad_config}); |
|
|
throw({error, bad_config}); |
|
|
determine_async_behavior(Sink, Threshold, undefined) -> |
|
|
|
|
|
|
|
|
tryStartAsyncer(Sink, Threshold, undefined) -> |
|
|
startThrottle(Sink, Threshold, erlang:trunc(Threshold * 0.2)); |
|
|
startThrottle(Sink, Threshold, erlang:trunc(Threshold * 0.2)); |
|
|
determine_async_behavior(_Sink, Threshold, Window) when not is_integer(Window) orelse Window > Threshold orelse Window < 0 -> |
|
|
|
|
|
error_logger:error_msg("Invalid value for 'async_threshold_window': ~p~n", [Window]), |
|
|
|
|
|
|
|
|
tryStartAsyncer(_Sink, Threshold, Window) when not is_integer(Window) orelse Window > Threshold orelse Window < 0 -> |
|
|
|
|
|
error_logger:error_msg("Invalid value for 'asyncThresholdWindow': ~p~n", [Window]), |
|
|
throw({error, bad_config}); |
|
|
throw({error, bad_config}); |
|
|
determine_async_behavior(Sink, Threshold, Window) -> |
|
|
|
|
|
|
|
|
tryStartAsyncer(Sink, Threshold, Window) -> |
|
|
startThrottle(Sink, Threshold, Window). |
|
|
startThrottle(Sink, Threshold, Window). |
|
|
|
|
|
|
|
|
startThrottle(Sink, Threshold, Window) -> |
|
|
startThrottle(Sink, Threshold, Window) -> |
|
|
_ = supervisor:start_child(rumHandlerWatcherSup, [Sink, ?RumBackendThrottle, [Threshold, Window]]), |
|
|
|
|
|
|
|
|
_ = supervisor:start_child(rumHWatcherSup, [Sink, ?RumBackendThrottle, [Threshold, Window]]), |
|
|
ok. |
|
|
ok. |
|
|
|
|
|
|
|
|
start_handlers(_Sink, undefined) -> |
|
|
start_handlers(_Sink, undefined) -> |
|
@ -214,7 +214,7 @@ configure_sink(Sink, SinkDef) -> |
|
|
rumConfig:initSink(Sink), |
|
|
rumConfig:initSink(Sink), |
|
|
ChildId = rumUtil:make_internal_sink_name(Sink), |
|
|
ChildId = rumUtil:make_internal_sink_name(Sink), |
|
|
_ = supervisor:start_child(eRum_sup, {ChildId, {gen_event, start_link, [{local, Sink}]}, permanent, 5000, worker, dynamic}), |
|
|
_ = supervisor:start_child(eRum_sup, {ChildId, {gen_event, start_link, [{local, Sink}]}, permanent, 5000, worker, dynamic}), |
|
|
determine_async_behavior(Sink, proplists:get_value(async_threshold, SinkDef), proplists:get_value(async_threshold_window, SinkDef)), |
|
|
|
|
|
|
|
|
tryStartAsyncer(Sink, proplists:get_value(asyncThreshold, SinkDef), proplists:get_value(asyncThresholdWindow, SinkDef)), |
|
|
_ = maybe_install_sink_killer(Sink, proplists:get_value(killer_hwm, SinkDef), |
|
|
_ = maybe_install_sink_killer(Sink, proplists:get_value(killer_hwm, SinkDef), |
|
|
proplists:get_value(killer_reinstall_after, SinkDef)), |
|
|
proplists:get_value(killer_reinstall_after, SinkDef)), |
|
|
start_handlers(Sink, proplists:get_value(handlers, SinkDef, [])), |
|
|
start_handlers(Sink, proplists:get_value(handlers, SinkDef, [])), |
|
|