Skip to content
Permalink
Browse files
Merge pull request #50 from avasenin/safely-notify
Add a error tolerance notify method
  • Loading branch information
joewilliams committed Jan 18, 2013
2 parents 79bd9d9 + 06fe802 commit ec3c29cde75a652e90530e89dc9c916891421237
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
@@ -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,
@@ -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).

@@ -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],

0 comments on commit ec3c29c

Please sign in to comment.