Skip to content
Permalink
Browse files
Expose the clear/1 fun from counter in the folsom api
Conflicts:
	test/folsom_erlang_checks.erl
  • Loading branch information
russelldb committed Jan 2, 2013
1 parent 95e006e commit abf8ea18af3ab0d7efc0df5160cae6775e88765a
Showing 2 changed files with 20 additions and 2 deletions.
@@ -313,6 +313,13 @@ notify(Name, {dec, Value}, counter, false) ->
add_handler(counter, Name),
folsom_metrics_counter:dec(Name, Value),
ok;
notify(Name, clear, counter, true) ->
folsom_metrics_counter:clear(Name),
ok;
notify(Name, clear, counter, false) ->
add_handler(counter, Name),
folsom_metrics_counter:clear(Name),
ok;
notify(Name, Value, gauge, true) ->
folsom_metrics_gauge:update(Name, Value),
ok;
@@ -45,6 +45,7 @@

create_metrics() ->
ok = folsom_metrics:new_counter(counter),
ok = folsom_metrics:new_counter(counter2),
ok = folsom_metrics:new_gauge(<<"gauge">>),

ok = folsom_metrics:new_histogram(<<"uniform">>, uniform, 5000),
@@ -80,14 +81,17 @@ create_metrics() ->
%% check a server got started for the spiral metric
1 = length(supervisor:which_children(folsom_sample_slide_sup)),

13 = length(folsom_metrics:get_metrics()),
14 = length(folsom_metrics:get_metrics()),

?debugFmt("~n~nmetrics: ~p~n", [folsom_metrics:get_metrics()]).

populate_metrics() ->
ok = folsom_metrics:notify({counter, {inc, 1}}),
ok = folsom_metrics:notify({counter, {dec, 1}}),

ok = folsom_metrics:notify({counter2, {inc, 10}}),
ok = folsom_metrics:notify({counter2, {dec, 7}}),

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

[ok = folsom_metrics:notify({<<"uniform">>, Value}) || Value <- ?DATA],
@@ -141,6 +145,12 @@ populate_metrics() ->
check_metrics() ->
0 = folsom_metrics:get_metric_value(counter),

3 = folsom_metrics:get_metric_value(counter2),

ok = folsom_metrics:notify_existing_metric(counter2, clear, counter),

0 = folsom_metrics:get_metric_value(counter2),

2 = folsom_metrics:get_metric_value(<<"gauge">>),

Histogram1 = folsom_metrics:get_histogram_statistics(<<"uniform">>),
@@ -202,9 +212,10 @@ check_metrics() ->


delete_metrics() ->
15 = length(ets:tab2list(?FOLSOM_TABLE)),
16 = length(ets:tab2list(?FOLSOM_TABLE)),

ok = folsom_metrics:delete_metric(counter),
ok = folsom_metrics:delete_metric(counter2),
ok = folsom_metrics:delete_metric(<<"gauge">>),

ok = folsom_metrics:delete_metric(<<"hugedata">>),

0 comments on commit abf8ea1

Please sign in to comment.