From 5e48148cbc8185e95300e7f8619e0a975be300b2 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Mon, 2 Oct 2023 09:22:43 +0200 Subject: [PATCH] Rename boundaries to explicit_bucket_boundaries --- .../include/otel_metrics.hrl | 2 +- .../otel_aggregation_histogram_explicit.erl | 20 +++++++++---------- .../src/otel_view.erl | 4 ++-- .../test/otel_metrics_SUITE.erl | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/opentelemetry_experimental/include/otel_metrics.hrl b/apps/opentelemetry_experimental/include/otel_metrics.hrl index ba48230c..16c008f2 100644 --- a/apps/opentelemetry_experimental/include/otel_metrics.hrl +++ b/apps/opentelemetry_experimental/include/otel_metrics.hrl @@ -62,7 +62,7 @@ start_time_unix_nano :: integer() | {const, eqwalizer:dynamic()} | '$9' | '$2' | undefined, %% instrument_temporality :: otel_aggregation:temporality(), %% default: [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0] - boundaries :: [float()] | match_spec([float()]), + explicit_bucket_boundaries :: [float()] | match_spec([float()]), record_min_max :: boolean() | match_spec(boolean()), checkpoint :: #explicit_histogram_checkpoint{} | match_spec(#explicit_histogram_checkpoint{}) | {#explicit_histogram_checkpoint{}}, bucket_counts :: counters:counters_ref() | match_spec(undefined), diff --git a/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl b/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl index 7981e556..cd8ade8c 100644 --- a/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl +++ b/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl @@ -136,12 +136,12 @@ init(#view_aggregation{name=Name, reader=ReaderId, aggregation_options=Options}, Attributes) -> Key = {Name, Attributes, ReaderId}, - Boundaries = maps:get(boundaries, Options, ?DEFAULT_BOUNDARIES), + ExplicitBucketBoundaries = maps:get(explicit_bucket_boundaries, Options, ?DEFAULT_BOUNDARIES), RecordMinMax = maps:get(record_min_max, Options, true), #explicit_histogram_aggregation{key=Key, start_time_unix_nano=erlang:system_time(nanosecond), - boundaries=Boundaries, - bucket_counts=new_bucket_counts(Boundaries), + explicit_bucket_boundaries=ExplicitBucketBoundaries, + bucket_counts=new_bucket_counts(ExplicitBucketBoundaries), checkpoint=undefined, record_min_max=RecordMinMax, min=infinity, %% works because any atom is > any integer @@ -153,17 +153,17 @@ aggregate(Table, #view_aggregation{name=Name, reader=ReaderId, aggregation_options=Options}, Value, Attributes) -> Key = {Name, Attributes, ReaderId}, - Boundaries = maps:get(boundaries, Options, ?DEFAULT_BOUNDARIES), + ExplicitBucketBoundaries = maps:get(explicit_bucket_boundaries, Options, ?DEFAULT_BOUNDARIES), try ets:lookup_element(Table, Key, #explicit_histogram_aggregation.bucket_counts) of BucketCounts0 -> BucketCounts = case BucketCounts0 of undefined -> - new_bucket_counts(Boundaries); + new_bucket_counts(ExplicitBucketBoundaries); _ -> BucketCounts0 end, - BucketIdx = find_bucket(Boundaries, Value), + BucketIdx = find_bucket(ExplicitBucketBoundaries, Value), counters:add(BucketCounts, BucketIdx, 1), MS = ?AGGREATE_MATCH_SPEC(Key, Value, BucketCounts), @@ -181,7 +181,7 @@ checkpoint(Tab, #view_aggregation{name=Name, temporality=?TEMPORALITY_DELTA}, CollectionStartNano) -> MS = [{#explicit_histogram_aggregation{key='$1', start_time_unix_nano='$9', - boundaries='$2', + explicit_bucket_boundaries='$2', record_min_max='$3', checkpoint='_', bucket_counts='$5', @@ -193,7 +193,7 @@ checkpoint(Tab, #view_aggregation{name=Name, {'=:=', {element, 3, '$1'}, {const, ReaderId}}], [{#explicit_histogram_aggregation{key='$1', start_time_unix_nano={const, CollectionStartNano}, - boundaries='$2', + explicit_bucket_boundaries='$2', record_min_max='$3', checkpoint={#explicit_histogram_checkpoint{bucket_counts='$5', min='$6', @@ -229,7 +229,7 @@ collect(Tab, #view_aggregation{name=Name, datapoint(CollectionStartNano, #explicit_histogram_aggregation{ key={_, Attributes, _}, - boundaries=Boundaries, + explicit_bucket_boundaries=Boundaries, start_time_unix_nano=StartTimeUnixNano, checkpoint=undefined, bucket_counts=BucketCounts, @@ -253,7 +253,7 @@ datapoint(CollectionStartNano, #explicit_histogram_aggregation{ }; datapoint(CollectionStartNano, #explicit_histogram_aggregation{ key={_, Attributes, _}, - boundaries=Boundaries, + explicit_bucket_boundaries=Boundaries, checkpoint=#explicit_histogram_checkpoint{bucket_counts=BucketCounts, min=Min, max=Max, diff --git a/apps/opentelemetry_experimental/src/otel_view.erl b/apps/opentelemetry_experimental/src/otel_view.erl index cc4749f6..9eaa24ac 100644 --- a/apps/opentelemetry_experimental/src/otel_view.erl +++ b/apps/opentelemetry_experimental/src/otel_view.erl @@ -125,10 +125,10 @@ match_instrument_to_views(Instrument=#instrument{name=InstrumentName, %% -aggragation_options(#{boundaries := _} = AggregationOptions, _AdvisoryParams) -> +aggragation_options(#{explicit_bucket_boundaries := _} = AggregationOptions, _AdvisoryParams) -> AggregationOptions; aggragation_options(AggregationOptions, #{explicit_bucket_boundaries := Boundaries}) -> - maps:put(boundaries, Boundaries, AggregationOptions); + maps:put(explicit_bucket_boundaries, Boundaries, AggregationOptions); aggragation_options(AggregationOptions, _AdvisoryParams) -> AggregationOptions. diff --git a/apps/opentelemetry_experimental/test/otel_metrics_SUITE.erl b/apps/opentelemetry_experimental/test/otel_metrics_SUITE.erl index c9dc1c18..6308472f 100644 --- a/apps/opentelemetry_experimental/test/otel_metrics_SUITE.erl +++ b/apps/opentelemetry_experimental/test/otel_metrics_SUITE.erl @@ -1183,10 +1183,10 @@ advisory_params(_Config) -> ct:fail(histogram_receive_timeout) end, - % boundaries from view have precedence + % explicit_bucket_boundaries from view have precedence ?assert(otel_meter_server:add_view(view, #{instrument_name => b_histogram}, #{ aggregation_module => otel_aggregation_histogram_explicit, - aggregation_options => #{boundaries => [10, 100]}})), + aggregation_options => #{explicit_bucket_boundaries => [10, 100]}})), HistogramB = otel_histogram:create(Meter, b_histogram, #{advisory_params => #{explicit_bucket_boundaries => [10, 20, 30]}}), @@ -1223,7 +1223,7 @@ histogram_aggregation_options(_Config) -> ?assert(otel_meter_server:add_view(view, #{instrument_name => histogram}, #{ aggregation_module => otel_aggregation_histogram_explicit, - aggregation_options => #{boundaries => [10, 100]}})), + aggregation_options => #{explicit_bucket_boundaries => [10, 100]}})), Histogram = otel_histogram:create(Meter, histogram, #{}),