Skip to content

Commit

Permalink
Merge pull request #50 from avasenin/safely-notify
Browse files Browse the repository at this point in the history
Add a error tolerance notify method
  • Loading branch information
joewilliams committed Jan 18, 2013
2 parents 79bd9d9 + 06fe802 commit ec3c29c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/folsom_metrics.erl
Expand Up @@ -44,6 +44,9 @@
notify/1,
notify/2,
notify/3,
safely_notify/1,
safely_notify/2,
safely_notify/3,
notify_existing_metric/3,
get_metrics/0,
metric_exists/1,
Expand Down Expand Up @@ -121,6 +124,15 @@ notify(Name, Event) ->
notify(Name, Event, Type) ->
folsom_ets:notify(Name, Event, Type).

safely_notify(Event) ->
catch notify(Event).

safely_notify(Name, Event) ->
catch notify(Name, Event).

safely_notify(Name, Event, Type) ->
catch notify(Name, Event, Type).

notify_existing_metric(Name, Event, Type) ->
folsom_ets:notify_existing_metric(Name, Event, Type).

Expand Down
5 changes: 5 additions & 0 deletions test/folsom_erlang_checks.erl
Expand Up @@ -94,6 +94,11 @@ populate_metrics() ->
ok = folsom_metrics:notify({counter2, {inc, 10}}),
ok = folsom_metrics:notify({counter2, {dec, 7}}),

meck:new(folsom_ets),
meck:expect(folsom_ets, notify, fun(_Event) -> meck:exception(error, something_wrong_with_ets) end),
{'EXIT', {something_wrong_with_ets, _}} = folsom_metrics:safely_notify({unknown_counter, {inc, 1}}),
meck:unload(folsom_ets),

ok = folsom_metrics:notify({<<"gauge">>, 2}),

[ok = folsom_metrics:notify({<<"uniform">>, Value}) || Value <- ?DATA],
Expand Down

0 comments on commit ec3c29c

Please sign in to comment.