Skip to content

Commit 710de34

Browse files
committed
Fix type specs
1 parent 8149dd7 commit 710de34

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
-ifndef(MATCH_SPEC_TYPES_DEFINED).
2+
13
-type match_var() :: '_' | '$1' | '$2' | '$3' | '$4' | '$5' | '$6' | '$7' | '$8' | '$9'.
24
-type match_spec(A) :: A | match_var() | {const, A}.
35

46
-define(MATCH_SPEC_TYPES_DEFINED, true).
7+
8+
-endif.

apps/opentelemetry_api_experimental/include/otel_metrics.hrl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
-ifndef(MATCH_SPEC_TYPES_DEFINED).
21
-include_lib("match_spec.hrl").
3-
-endif.
42

53
-record(instrument, {module :: match_spec(module()),
64
meter :: match_spec(otel_meter:t()),

apps/opentelemetry_experimental/include/otel_metrics.hrl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
-ifndef(MATCH_SPEC_TYPES_DEFINED).
21
-include_lib("opentelemetry_api_experimental/include/match_spec.hrl").
3-
-endif.
42

53
-define(DEFAULT_METER_PROVIDER, otel_meter_provider_default).
64

5+
-type key_inner_match_spec() :: {match_spec(atom()), match_spec(opentelemetry:attributes_map()), match_spec(reference())}.
6+
-type key_match_spec() :: match_spec(otel_aggregation:key()) | key_inner_match_spec() | {key_inner_match_spec()}.
7+
78
-record(meter,
89
{
910
module :: module() | '_',
@@ -26,7 +27,7 @@
2627
-record(sum_aggregation,
2728
{
2829
%% TODO: attributes should be a tuple of just the values, sorted by attribute name
29-
key :: match_spec(otel_aggregation:key()) | otel_aggregation:key_match_spec() | undefined | {element, 2, '$_'},
30+
key :: key_match_spec() | undefined | {element, 2, '$_'},
3031
start_time_unix_nano :: match_spec(integer()) | undefined,
3132
last_start_time_unix_nano :: match_spec(integer()) | undefined,
3233
checkpoint :: match_spec(number()) | undefined | {'+', '$2', '$3'} | {'+', '$3', '$4'},
@@ -38,7 +39,7 @@
3839
-record(last_value_aggregation,
3940
{
4041
%% TODO: attributes should be a tuple of just the values, sorted by attribute name
41-
key :: match_spec(otel_aggregation:key()) | otel_aggregation:key_match_spec() | undefined,
42+
key :: key_match_spec() | undefined,
4243
checkpoint :: match_spec(number()) | undefined,
4344
value :: match_spec(number()) | undefined,
4445
start_time_unix_nano :: match_spec(integer()) | undefined,
@@ -58,8 +59,8 @@
5859
-record(explicit_histogram_aggregation,
5960
{
6061
%% TODO: attributes should be a tuple of just the values, sorted by attribute name
61-
key :: match_spec(otel_aggregation:key()) | otel_aggregation:key_match_spec() | undefined,
62-
start_time_unix_nano :: integer() | {const, eqwalizer:dynamic()} | '$9' | '$2' | undefined,
62+
key :: key_match_spec() | undefined,
63+
start_time_unix_nano :: match_spec(integer()) | undefined,
6364
%% instrument_temporality :: otel_aggregation:temporality(),
6465
%% default: [0.0, 5.0, 10.0, 25.0, 50.0, 75.0, 100.0, 250.0, 500.0, 1000.0]
6566
explicit_bucket_boundaries :: match_spec([float()]) | undefined,

apps/opentelemetry_experimental/src/otel_aggregation.erl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
otel_aggregation_last_value:t() | otel_aggregation_histogram_explicit:t().
1313

1414
-type key() :: {atom(), opentelemetry:attributes_map(), reference()}.
15-
-type key_match_spec() :: match_spec(otel_aggregation:key()) | {match_spec(atom()), match_spec(opentelemetry:attributes_map()), match_spec(reference())}.
1615

1716
-type options() :: map().
1817

1918
-export_type([t/0,
2019
key/0,
21-
key_match_spec/0,
2220
options/0]).
2321

2422
%% Returns the aggregation's record as it is seen and updated by

apps/opentelemetry_experimental/src/otel_meter_server.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ add_view_(Name, Criteria, Config, InstrumentsTab, CallbacksTab, ViewAggregations
258258
{ok, NewView} ->
259259
_ = update_view_aggregations(InstrumentsTab, CallbacksTab, ViewAggregationsTab, [NewView], Readers),
260260
{reply, true, State#state{views=[NewView | Views]}};
261-
error ->
261+
{error, named_wildcard_view} ->
262262
{reply, false, State}
263263
end.
264264

@@ -299,7 +299,7 @@ new_view(ViewConfig) ->
299299
aggregation_options => AggregationOptions
300300
}) of
301301
{ok, View} -> {true, View};
302-
error -> false
302+
{error, named_wildcard_view} -> false
303303
end.
304304

305305
%% Match the Instrument to views and then store a per-Reader aggregation for the View

apps/opentelemetry_experimental/src/otel_view.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@
5252
-include_lib("opentelemetry_api/include/gradualizer.hrl").
5353

5454

55-
-spec new(criteria() | undefined, config()) -> {ok, t()} | error.
55+
-spec new(criteria() | undefined, config()) -> {ok, t()} | {error, named_wildcard_view}.
5656
new(Criteria, Config) ->
5757
new(undefined, Criteria, Config).
5858

59-
-spec new(name(), criteria() | undefined, config()) -> {ok, t()} | error.
59+
-spec new(name(), criteria() | undefined, config()) -> {ok, t()} | {error, named_wildcard_view}.
6060
new(undefined, Criteria, Config) ->
6161
{ok, do_new(Criteria, Config)};
6262
new(Name, #{instrument_name := '*'}, _Config) ->
6363
?LOG_INFO("Wildacrd Views can not have a name, discarding view ~s", [Name]),
64-
error;
64+
{error, named_wildcard_view};
6565
new(Name, Criteria, Config) ->
6666
View = do_new(Criteria, Config),
6767
{ok, View#view{name=Name}}.

apps/opentelemetry_experimental/test/otel_metrics_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ wildcard_view(_Config) ->
485485
?assertMatch([{#view{}, _}], otel_view:match_instrument_to_views(Counter, [View])),
486486

487487
%% not possible to create wildcard views with a name
488-
error = otel_view:new(view_name, ViewCriteria, ViewConfig),
488+
{error, named_wildcard_view} = otel_view:new(view_name, ViewCriteria, ViewConfig),
489489

490490
ok.
491491

0 commit comments

Comments
 (0)