Skip to content

Commit

Permalink
use -2^63 for the initial min value in explicit histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan Sloughter committed Aug 8, 2022
1 parent c895ce8 commit 1baebe3
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

-define(DEFAULT_BOUNDARIES, [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0]).

-define(MIN_DOUBLE, -9223372036854775807.0). %% the proto representation of size `fixed64'

init(Key, Options) ->
Boundaries = maps:get(boundaries, Options, ?DEFAULT_BOUNDARIES),
RecordMinMax = maps:get(record_min_max, Options, true),
Expand All @@ -39,7 +41,7 @@ init(Key, Options) ->
bucket_counts=zero_buckets(length(Boundaries)),
record_min_max=RecordMinMax,
min=infinity, %% works because any atom is > any integer
max=neg_infinity, %% requires an explicit check
max=?MIN_DOUBLE,
sum=0
}.

Expand Down Expand Up @@ -67,10 +69,7 @@ aggregate(MeasurementValue,
Buckets1 = bump_bucket_counts(MeasurementValue, Boundaries, Buckets),
Aggregation#explicit_histogram_aggregation{bucket_counts=Buckets1,
min=min(Min, MeasurementValue),
max=case Max of
neg_infinity -> MeasurementValue;
_ -> max(Max, MeasurementValue)
end,
max=max(Max, MeasurementValue),
sum=Sum+MeasurementValue};
aggregate(MeasurementValue,
Aggregation=#explicit_histogram_aggregation{boundaries=Boundaries,
Expand Down

0 comments on commit 1baebe3

Please sign in to comment.