Erlang StatsD client
Add statse to your .app file:
{ applications, [ statse ] }default parameters can be overridden via your sys.config:
{   statse,
	[
		{ statsd_host, "localhost" },
		{ statsd_port,	8125 },
		{ stat_prefix, "node.local" }
	]
}Lager backend can be added via your lager config:
{ lager, [ { handlers, [ { statse_lager_backend, debug } ] } ] }In addition to the standard StatsD metrics, statse provides the following features:
stat_prefix config parameter can be used to add a node-level prefix to every stat name sent to StatsD.
statse can be configured to periodically call a fun and log the result as a gauge value.
statse_gauge_monitor:start_monitor( StatKey, StatFun, RefreshPeriod )where StatFun is a zero arity fun that returns a number() or { ok, number() }
Examples:
Start monitoring:
statse_gauge_monitor:start_monitor( "vm.memory", fun() -> erlang:memory( total ) end, timer:minutes( 5 ) )Stop monitoring:
statse_gauge_monitor:stop_monitor( "vm.memory" )Calling start_monitor with a duplicate key will cause the old monitor to be discarded. A StatFun that throws an exception will cause the monitor for that stat to be discarded.
statse:increment( StatKey )
statse:increment( StatKey, SampleRate )statse:decrement( StatKey )
statse:decrement( StatKey, SampleRate )statse:count( StatKey, Value )
statse:count( StatKey, Value, SampleRate )statse:timing( StatKey, Milliseconds )
statse:timing( StatKey, Milliseconds, SampleRate )or
StartTime = os:timestamp(),
%% do_work...
statse:timing( StatKey, StartTime )
statse:timing( StatKey, StartTime, SampleRate )statse:gauge( StatKey, Value )statse:gauge_change( StatKey, Delta )statse:set( StatKey, Value )make test
make dialyzer