Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treshold or Trigger #146

Open
hwinkel opened this issue Feb 10, 2016 · 1 comment
Open

Treshold or Trigger #146

hwinkel opened this issue Feb 10, 2016 · 1 comment

Comments

@hwinkel
Copy link

hwinkel commented Feb 10, 2016

Is there any functionality to raise a event based on given threshold or trigger?

@uwiger
Copy link
Member

uwiger commented Feb 11, 2016

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 Feuerlabs/exometer_core#68 which fixes the return value of exometer:update/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants