diff --git a/apps/opentelemetry_api_experimental/include/match_spec.hrl b/apps/opentelemetry_api_experimental/include/match_spec.hrl new file mode 100644 index 00000000..d1ddb70a --- /dev/null +++ b/apps/opentelemetry_api_experimental/include/match_spec.hrl @@ -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). diff --git a/apps/opentelemetry_api_experimental/include/otel_metrics.hrl b/apps/opentelemetry_api_experimental/include/otel_metrics.hrl index 5446cf2e..81f08447 100644 --- a/apps/opentelemetry_api_experimental/include/otel_metrics.hrl +++ b/apps/opentelemetry_api_experimental/include/otel_metrics.hrl @@ -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). diff --git a/apps/opentelemetry_experimental/include/otel_metrics.hrl b/apps/opentelemetry_experimental/include/otel_metrics.hrl index ba48230c..15f107fc 100644 --- a/apps/opentelemetry_experimental/include/otel_metrics.hrl +++ b/apps/opentelemetry_experimental/include/otel_metrics.hrl @@ -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, { @@ -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, @@ -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, diff --git a/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl b/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl index 7981e556..af7c26d5 100644 --- a/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl +++ b/apps/opentelemetry_experimental/src/otel_aggregation_histogram_explicit.erl @@ -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) -> diff --git a/apps/opentelemetry_experimental/src/otel_aggregation_last_value.erl b/apps/opentelemetry_experimental/src/otel_aggregation_last_value.erl index ff699139..7367b083 100644 --- a/apps/opentelemetry_experimental/src/otel_aggregation_last_value.erl +++ b/apps/opentelemetry_experimental/src/otel_aggregation_last_value.erl @@ -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) -> diff --git a/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl b/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl index addc2482..36aea577 100644 --- a/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl +++ b/apps/opentelemetry_experimental/src/otel_aggregation_sum.erl @@ -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) -> diff --git a/apps/opentelemetry_experimental/src/otel_meter_server.erl b/apps/opentelemetry_experimental/src/otel_meter_server.erl index 66e15aa8..8c752742 100644 --- a/apps/opentelemetry_experimental/src/otel_meter_server.erl +++ b/apps/opentelemetry_experimental/src/otel_meter_server.erl @@ -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} -> @@ -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), diff --git a/apps/opentelemetry_experimental/src/otel_meter_server_sup.erl b/apps/opentelemetry_experimental/src/otel_meter_server_sup.erl index dcba7606..90178964 100644 --- a/apps/opentelemetry_experimental/src/otel_meter_server_sup.erl +++ b/apps/opentelemetry_experimental/src/otel_meter_server_sup.erl @@ -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), diff --git a/apps/opentelemetry_experimental/src/otel_view.erl b/apps/opentelemetry_experimental/src/otel_view.erl index 35c8a9ed..10e913b6 100644 --- a/apps/opentelemetry_experimental/src/otel_view.erl +++ b/apps/opentelemetry_experimental/src/otel_view.erl @@ -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)}; @@ -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), @@ -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, @@ -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 = @@ -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}}}. diff --git a/apps/opentelemetry_experimental/src/otel_view.hrl b/apps/opentelemetry_experimental/src/otel_view.hrl index 84800f63..7044c91f 100644 --- a/apps/opentelemetry_experimental/src/otel_view.hrl +++ b/apps/opentelemetry_experimental/src/otel_view.hrl @@ -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,