Treshold or Trigger
Is there any functionality to raise a event based on given threshold or trigger?
There is something that is not yet documented. If you specify the option {update_event, true} (either via exometer:new/3 or exometer:setopts/2), exometer will send a message to a process registered as exometer_event. By default, there is no such process, and at least for now, exometer has no opinion about how it should behave; its only interaction with it is to send {updated, Metric, Value} messages to it when called for. Note that Value is the value passed to update/2 - not the value of the metric. If you want to act on the metric value, you have to fetch it after receiving the message. The reason for this is that get_value/2 can be "expensive" for certain metrics.
Eshell V6.3 (abort with ^G)
1> exometer:start().
ok
2> Recv = fun R() -> receive M -> io:fwrite("<-- ~p~n", [M]), R() end end.
#Fun<erl_eval.44.90072148>
3> Event = spawn(fun() -> register(exometer_event, self()), Recv() end).
<0.89.0>
4> exometer_event ! test.
<-- test
test
5> exometer:new([c,1], counter, [{update_event,true}]).
ok
6> exometer:new([c,2], counter, []). % no update events should be sent
ok
7> exometer:update([c,1], 1).
<-- {updated,[c,1],1}
ok
8> exometer:update([c,2], 1).
ok
9> exometer:update([c,1], 1).
<-- {updated,[c,1],1}
ok
Note that this example assumes exometer_core PR https://github.com/Feuerlabs/exometer_core/pull/68 which fixes the return value of exometer:update/2