Skip to content

Commit

Permalink
No more needed to check for pos numbers in sum aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
albertored committed Nov 5, 2023
1 parent 041af5d commit 9926c65
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions apps/opentelemetry_experimental/src/otel_aggregation_sum.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ init(#view_aggregation{name=Name,
float_value=0.0}.

aggregate(Tab, #view_aggregation{name=Name,
reader=ReaderId,
is_monotonic=IsMonotonic}, Value, Attributes)
when is_integer(Value) andalso
((IsMonotonic andalso Value >= 0) orelse not IsMonotonic) ->
reader=ReaderId}, Value, Attributes)
when is_integer(Value) ->
Key = {Name, Attributes, ReaderId},
try
_ = ets:update_counter(Tab, Key, {#sum_aggregation.int_value, Value}),
Expand All @@ -65,9 +63,7 @@ aggregate(Tab, #view_aggregation{name=Name,
false
end;
aggregate(Tab, #view_aggregation{name=Name,
reader=ReaderId,
is_monotonic=IsMonotonic}, Value, Attributes)
when (IsMonotonic andalso Value >= 0.0) orelse not IsMonotonic ->
reader=ReaderId}, Value, Attributes) ->
Key = {Name, Attributes, ReaderId},
MS = [{#sum_aggregation{key=Key,
start_time_unix_nano='$1',
Expand All @@ -84,10 +80,7 @@ aggregate(Tab, #view_aggregation{name=Name,
previous_checkpoint='$6',
int_value='$3',
float_value={'+', '$4', {const, Value}}}}]}],
1 =:= ets:select_replace(Tab, MS);
aggregate(_Tab, #view_aggregation{name=_Name,
is_monotonic=_IsMonotonic}, _Value, _) ->
false.
1 =:= ets:select_replace(Tab, MS).

-dialyzer({nowarn_function, checkpoint/3}).
checkpoint(Tab, #view_aggregation{name=Name,
Expand Down

0 comments on commit 9926c65

Please sign in to comment.