Skip to content

Commit

Permalink
remove some dialyzer ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
albertored committed Sep 20, 2023
1 parent 8ce874b commit 960e7a9
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 58 deletions.
4 changes: 4 additions & 0 deletions apps/opentelemetry_api_experimental/include/match_spec.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-type match_var() :: '_' | '$1' | '$2' | '$3' | '$4' | '$5' | '$6' | '$7' | '$8' | '$9'.
-type match_spec(A) :: A | match_var() | {const, A}.

-define(MATCH_SPEC_TYPES_DEFINED, true).
22 changes: 13 additions & 9 deletions apps/opentelemetry_api_experimental/include/otel_metrics.hrl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
-record(instrument, {module :: module(),
meter :: otel_meter:t(),
name :: otel_instrument:name(),
description :: otel_instrument:description() | undefined,
kind :: otel_instrument:kind(),
unit :: otel_instrument:unit() | undefined,
temporality :: otel_instrument:temporality(),
callback :: otel_instrument:callback() | undefined,
callback_args :: otel_instrument:callback_args() | undefined}).
-ifndef(MATCH_SPEC_TYPES_DEFINED).
-include_lib("match_spec.hrl").
-endif.

-record(instrument, {module :: match_spec(module()),
meter :: match_spec(otel_meter:t()),
name :: match_spec(otel_instrument:name()),
description :: match_spec(otel_instrument:description()) | undefined,
kind :: match_spec(otel_instrument:kind()),
unit :: match_spec(otel_instrument:unit()) | undefined,
temporality :: match_spec(otel_instrument:temporality()),
callback :: match_spec(otel_instrument:callback()) | undefined,
callback_args :: match_spec(otel_instrument:callback_args()) | undefined}).

-define(TEMPORALITY_DELTA, temporality_delta).
-define(TEMPORALITY_CUMULATIVE, temporality_cumulative).
Expand Down
66 changes: 33 additions & 33 deletions apps/opentelemetry_experimental/include/otel_metrics.hrl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-define(DEFAULT_METER_PROVIDER, otel_meter_provider_default).
-ifndef(MATCH_SPEC_TYPES_DEFINED).
-include_lib("opentelemetry_api_experimental/include/match_spec.hrl").
-endif.

-type match_var() :: '_' | '$1' | '$2' | '$3' | '$4' | '$5' | '$6' | '$7' | '$8' | '$9'.
-type match_expr(A) :: undefined | match_var() | {const, A}.
-type match_spec(A) :: match_expr(A).
-define(DEFAULT_METER_PROVIDER, otel_meter_provider_default).

-record(meter,
{
Expand All @@ -26,49 +26,49 @@
-record(sum_aggregation,
{
%% TODO: attributes should be a tuple of just the values, sorted by attribute name
key :: otel_aggregation:key() | match_spec(otel_aggregation:key()) | {element, 2, '$_'},
start_time_unix_nano :: integer() | match_spec(integer()),
last_start_time_unix_nano :: integer() | match_spec(integer()),
checkpoint :: number() | match_spec(number()) | {'+', '$2', '$3'} | {'+', '$3', '$4'},
previous_checkpoint :: number() | match_spec(number()) | {'+', '$5', '$6'},
int_value :: number() | match_spec(number()) | {'+', '$3', {const, number()}},
float_value :: number() | match_spec(number()) | {'+', '$4', {const, number()}}
key :: match_spec(otel_aggregation:key()) | undefined | {element, 2, '$_'},
start_time_unix_nano :: match_spec(integer()) | undefined,
last_start_time_unix_nano :: match_spec(integer()) | undefined,
checkpoint :: match_spec(number()) | undefined | {'+', '$2', '$3'} | {'+', '$3', '$4'},
previous_checkpoint :: match_spec(number()) | undefined | {'+', '$5', '$6'},
int_value :: match_spec(number()) | undefined | {'+', '$3', {const, number()}},
float_value :: match_spec(number()) | undefined | {'+', '$4', {const, number()}}
}).

-record(last_value_aggregation,
{
%% TODO: attributes should be a tuple of just the values, sorted by attribute name
key :: otel_aggregation:key() | match_spec(otel_aggregation:key()),
checkpoint :: number() | match_spec(number()),
value :: number() | match_spec(number()),
start_time_unix_nano :: integer() | match_spec(integer()),
last_start_time_unix_nano :: integer() | match_spec(integer())
key :: match_spec(otel_aggregation:key()) | undefined,
checkpoint :: match_spec(number()) | undefined,
value :: match_spec(number()) | undefined,
start_time_unix_nano :: match_spec(integer()) | undefined,
last_start_time_unix_nano :: match_spec(integer()) | undefined
}).


-record(explicit_histogram_checkpoint,
{
bucket_counts :: counters:counters_ref() | match_spec(counters:counters_ref()),
min :: number() | match_spec(number()),
max :: number() | match_spec(number()),
sum :: number() | match_spec(number()),
start_time_unix_nano :: integer() | match_spec(number())
bucket_counts :: match_spec(counters:counters_ref()) | undefined,
min :: match_spec(number()) | undefined,
max :: match_spec(number()) | undefined,
sum :: match_spec(number()) | undefined,
start_time_unix_nano :: match_spec(number()) | undefined
}).

-record(explicit_histogram_aggregation,
{
%% TODO: attributes should be a tuple of just the values, sorted by attribute name
key :: otel_aggregation:key() | match_spec(otel_aggregation:key()),
key :: match_spec(otel_aggregation:key()) | undefined,
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()]),
record_min_max :: boolean() | match_spec(boolean()),
checkpoint :: #explicit_histogram_checkpoint{} | match_spec(#explicit_histogram_checkpoint{}) | {#explicit_histogram_checkpoint{}},
boundaries :: match_spec([float()]) | undefined,
record_min_max :: match_spec(boolean()) | undefined,
checkpoint :: match_spec(#explicit_histogram_checkpoint{}) | {#explicit_histogram_checkpoint{}} | undefined,
bucket_counts :: counters:counters_ref() | match_spec(undefined),
min :: number() | infinity | match_spec(number()),
max :: number() | match_spec(number()),
sum :: number() | match_spec(number())
min :: infinity | match_spec(number()) | undefined,
max :: match_spec(number()) | undefined,
sum :: match_spec(number()) | undefined
}).

-record(datapoint,
Expand Down Expand Up @@ -96,16 +96,16 @@
-record(histogram_datapoint,
{
attributes :: opentelemetry:attributes_map(),
start_time_unix_nano :: integer() | match_spec(integer()) | {const, eqwalizer:dynamic()},
start_time_unix_nano :: match_spec(integer()) | {const, eqwalizer:dynamic()} | undefined,
time_unix_nano :: integer(),
count :: number(),
sum :: float() | match_spec(integer()),
sum :: float() | match_spec(integer()) | undefined,
bucket_counts :: list(),
explicit_bounds :: [float()] | match_spec([float()]),
explicit_bounds :: match_spec([float()]) | undefined,
exemplars :: list(),
flags :: integer(),
min :: integer() | infinity | match_spec(integer()),
max :: integer() | match_spec(integer())
min :: infinity | match_spec(integer()) | undefined,
max :: match_spec(integer()) | undefined
}).

-record(histogram,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ aggregate(Table, #view_aggregation{name=Name,
false
end.

-dialyzer({nowarn_function, checkpoint/3}).
checkpoint(Tab, #view_aggregation{name=Name,
reader=ReaderId,
temporality=?TEMPORALITY_DELTA}, CollectionStartNano) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ aggregate(Tab, ViewAggregation=#view_aggregation{name=Name,
ets:insert(Tab, ?assert_type((?assert_type(Metric, #last_value_aggregation{}))#last_value_aggregation{value=Value}, tuple()))
end.

-dialyzer({nowarn_function, checkpoint/3}).
checkpoint(Tab, #view_aggregation{name=Name,
reader=ReaderId,
temporality=?TEMPORALITY_DELTA}, CollectionStartNano) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ aggregate(_Tab, #view_aggregation{name=_Name,
is_monotonic=_IsMonotonic}, _Value, _) ->
false.

-dialyzer({nowarn_function, checkpoint/3}).
checkpoint(Tab, #view_aggregation{name=Name,
reader=ReaderPid,
temporality=?TEMPORALITY_DELTA}, CollectionStartNano) ->
Expand Down
2 changes: 0 additions & 2 deletions apps/opentelemetry_experimental/src/otel_meter_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ code_change(State) ->

%%

-dialyzer({nowarn_function,add_view_/9}).
add_view_(Name, Criteria, Config, InstrumentsTab, CallbacksTab, ViewAggregationsTab, Readers, Views, State) ->
case otel_view:new(Name, Criteria, Config) of
{ok, NewView} ->
Expand Down Expand Up @@ -287,7 +286,6 @@ metrics_tab(Name) ->
{keypos, 2},
public]).

-dialyzer({nowarn_function,new_view/1}).
new_view(ViewConfig) ->
Name = maps:get(name, ViewConfig, undefined),
Description = maps:get(description, ViewConfig, undefined),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
start_link(Name, Resource, Opts) ->
supervisor:start_link(?MODULE, [Name, Resource, Opts]).

-dialyzer({nowarn_function, provider_pid/1}).
-spec provider_pid(supervisor:sup_ref()) -> pid() | restarting | undefined.
provider_pid(SupPid) ->
Children = supervisor:which_children(SupPid),
Expand Down
9 changes: 0 additions & 9 deletions apps/opentelemetry_experimental/src/otel_view.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@
-include_lib("opentelemetry_api/include/gradualizer.hrl").


-dialyzer({nowarn_function,new/2}).
-spec new(criteria() | undefined, config()) -> {ok, t()} | error.
new(Criteria, Config) ->
new(undefined, Criteria, Config).

-dialyzer({nowarn_function,new/3}).
-spec new(name(), criteria() | undefined, config()) -> {ok, t()} | error.
new(undefined, Criteria, Config) ->
{ok, do_new(Criteria, Config)};
Expand All @@ -70,7 +68,6 @@ new(Name, Criteria, Config) ->

%% no name means Instrument name is used
%% must reject wildcard Criteria in this case
-dialyzer({nowarn_function,do_new/2}).
do_new(Criteria, Config) ->
CriteriaInstrumentName = view_name_from_criteria(Criteria),
Matchspec = criteria_to_instrument_matchspec(Criteria),
Expand All @@ -83,7 +80,6 @@ do_new(Criteria, Config) ->
aggregation_module=maps:get(aggregation_module, Config, undefined),
aggregation_options=maps:get(aggregation_options, Config, #{})}.

-dialyzer({nowarn_function,match_instrument_to_views/2}).
-spec match_instrument_to_views(otel_instrument:t(), [t()]) -> [{t() | undefined, #view_aggregation{}}].
match_instrument_to_views(Instrument=#instrument{name=InstrumentName,
meter=Meter,
Expand Down Expand Up @@ -136,7 +132,6 @@ value_or(undefined, Other) ->
value_or(Value, _Other) ->
Value.

-dialyzer({nowarn_function,criteria_to_instrument_matchspec/1}).
-spec criteria_to_instrument_matchspec(map() | undefined) -> ets:comp_match_spec().
criteria_to_instrument_matchspec(Criteria) when is_map(Criteria) ->
Instrument =
Expand Down Expand Up @@ -167,20 +162,16 @@ criteria_to_instrument_matchspec(_) ->
%% eqwalizer:ignore building a matchspec and don't want '_' polluting the type
ets:match_spec_compile([{#instrument{_='_'}, [], [true]}]).

-dialyzer({nowarn_function,maybe_init_meter/1}).
maybe_init_meter(#instrument{meter='_'}) ->
{'_', #meter{instrumentation_scope=#instrumentation_scope{_='_'},
_='_'}}.

-dialyzer({nowarn_function,update_meter_name/2}).
update_meter_name(MeterName, {_, Meter=#meter{instrumentation_scope=Scope}}) ->
{'_', Meter#meter{instrumentation_scope=Scope#instrumentation_scope{name=MeterName}}}.

-dialyzer({nowarn_function,update_meter_version/2}).
update_meter_version(MeterVersion, {_, Meter=#meter{instrumentation_scope=Scope}}) ->
{'_', Meter#meter{instrumentation_scope=Scope#instrumentation_scope{version=MeterVersion}}}.

-dialyzer({nowarn_function,update_meter_schema_url/2}).
update_meter_schema_url(SchemaUrl, {_, Meter=#meter{instrumentation_scope=Scope}}) ->
{'_', Meter#meter{instrumentation_scope=Scope#instrumentation_scope{schema_url=SchemaUrl}}}.

Expand Down
2 changes: 1 addition & 1 deletion apps/opentelemetry_experimental/src/otel_view.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
name :: atom(),
scope :: opentelemetry:instrumentation_scope(),
instrument :: otel_instrument:t(),
reader :: reference(),
reader :: reference() | undefined,

attribute_keys :: [opentelemetry:attribute_key()] | undefined,

Expand Down

0 comments on commit 960e7a9

Please sign in to comment.