Closed puzza007 closed 9 years ago
Example of use
puzza@Pauls-iMac ~/src/folsom (update-counter-without-catching-exceptions) $ erl -pa ebin -pa deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
Eshell V5.10.3 (abort with ^G)
1> application:ensure_all_started(folsom).
{ok,[bear,folsom]}
2> ok = folsom_metrics:new_spiral(spiral).
ok
3> ok = folsom_metrics:new_spiral(spiral_no_exceptions, no_exceptions).
ok
4> erl
erl_distribution erl_eval erl_internal
erl_lint erl_parse erl_prim_loader
erl_scan erlang
4> erlang:get
get/0 get/1 get_cookie/0 get_keys/1
get_module_info/1 get_module_info/2 get_stacktrace/0
4> erlang:get_stacktrace().
[]
5> folsom_metrics:notify_existing_metric(spiral, 100, spiral).
ok
6> erlang:get_stacktrace().
[{ets,update_counter,[16409,{1423493422,4},100],[]},
{folsom_utils,update_counter,3,
[{file,"src/folsom_utils.erl"},{line,69}]},
{folsom_metrics_spiral,update,2,
[{file,"src/folsom_metrics_spiral.erl"},{line,65}]},
{folsom_ets,notify,4,
[{file,"src/folsom_ets.erl"},{line,431}]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,573}]},
{shell,exprs,7,[{file,"shell.erl"},{line,674}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,629}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,614}]}]
7>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
^C% puzza@Pauls-iMac ~/src/folsom (update-counter-without-catching-exceptions) $ erl -pa ebin -pa deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
Eshell V5.10.3 (abort with ^G)
1> application:ensure_all_started(folsom).
{ok,[bear,folsom]}
2> ok = folsom_metrics:new_spiral(spiral).
ok
3> ok = folsom_metrics:new_spiral(spiral_no_exceptions, no_exceptions).
ok
4> folsom_metrics:notify_existing_metric(spiral_no_exceptions, 200, spiral).
ok
5> erlang:get_stacktrace().
[]
6>
This adds new_spiral(Name, Update) where update is one of
fast
orno_exceptions
.fast
works by catching thebadarg
on update of a non-existant key.no_exceptions
instead reads the ETS table first to avoid catching an exception. The reason for this is that if one uses a spiral in a cowboy onresponse function, if there's an exception thrown by the handler it'll be overwritten by folsom. Maybe there's another way around this? (there's definitely https://github.com/erlang/otp/pull/362, but I don't want to have to upgrade OTP, or wait until it's merged)