Skip to content

Commit

Permalink
simplify counter:(d)inc type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
deadtrickster committed Apr 27, 2017
1 parent db87616 commit 47ee802
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/metrics/prometheus_counter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ inc(Name, LabelValues, Value) ->
%% Raises `{invalid_metric_arity, Present, Expected}' error if labels count
%% mismatch.
%% @end
inc(_Registry, _Name, _LabelValues, Value) when Value < 0 ->
erlang:error({invalid_value, Value,
"inc accepts only non-negative integers"});
inc(Registry, Name, LabelValues, Value) when is_integer(Value) ->
inc(Registry, Name, LabelValues, Value) when is_integer(Value), Value >= 0 ->
try
ets:update_counter(?TABLE,
key(Registry, Name, LabelValues),
Expand Down Expand Up @@ -235,10 +232,7 @@ dinc(Name, LabelValues, Value) ->
%% Raises `{invalid_metric_arity, Present, Expected}' error if labels count
%% mismatch.
%% @end
dinc(_Registry, _Name, _LabelValues, Value) when Value < 0 ->
erlang:error({invalid_value, Value,
"dinc accepts only non-negative numbers"});
dinc(Registry, Name, LabelValues, Value) when is_number(Value) ->
dinc(Registry, Name, LabelValues, Value) when is_number(Value), Value >= 0 ->
MF = prometheus_metric:check_mf_exists(?TABLE, Registry, Name, LabelValues),
CallTimeout = prometheus_metric:mf_call_timeout(MF),
case CallTimeout of
Expand Down

0 comments on commit 47ee802

Please sign in to comment.