From 9926c65e3d9f25288e3ee09a11dc1475b331a58e Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Sun, 5 Nov 2023 14:39:22 +0100 Subject: [PATCH] No more needed to check for pos numbers in sum aggregation --- .../src/otel_aggregation_sum.erl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl b/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl index 1e03eaca..38cc369a 100644 --- a/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl +++ b/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl @@ -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}), @@ -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', @@ -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,