Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit d690a63

Browse files
committed
BREAKING CHANGE! remove common tags
Removes common tags and instead forces user to use regular tags with properly set values.
1 parent b73a12f commit d690a63

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/oc_stat_view.erl

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
deregister/1,
3030
is_registered/1,
3131
subscribe/1,
32-
subscribe/5,
32+
subscribename(), /5,
3333
subscribe/6,
3434
unsubscribe/1,
3535
is_subscribed/1,
@@ -72,7 +72,6 @@
7272
unit :: oc_stat_measure:unit(),
7373
subscribed = false :: boolean(),
7474
description = "" :: description() | '_',
75-
ctags = #{} :: oc_tags:tags() | '_',
7675
tags = [] :: [oc_tags:key()] | '_',
7776
aggregation :: aggregation() | '_',
7877
aggregation_options = [] :: aggregation_options() | '_'}).
@@ -86,7 +85,6 @@
8685
-type description() :: binary() | string().
8786
-type view_data() :: #{name := name(),
8887
description := description(),
89-
ctags := oc_tags:tags(),
9088
tags := [oc_tags:key()],
9189
data := oc_stat_aggregation:data()}.
9290
-type view() :: #view{}.
@@ -95,6 +93,12 @@
9593
%% @doc
9694
%% Creates a View from a map.
9795
%% @end
96+
-spec new(#{name => name(),
97+
measure => measure_name() | oc_stat_measure:measure(),
98+
description => description(),
99+
unit := oc_stat_measure:unit(),
100+
tags := [oc_tags:key()],
101+
aggregation => aggregation()}) -> view().
98102
new(Map) when is_map(Map) ->
99103
new(maps:get(name, Map), maps:get(measure, Map), maps:get(unit, Map, undefined),
100104
maps:get(description, Map), maps:get(tags, Map, []), maps:get(aggregation, Map)).
@@ -103,18 +107,27 @@ new(Map) when is_map(Map) ->
103107
%% Creates a View. This view needs to be registered and subscribed to a measure
104108
%% in order to start aggregating data.
105109
%% @end
110+
-spec new(name(),
111+
measure_name() | oc_stat_measure:measure(),
112+
description(),
113+
[oc_tags:key()],
114+
aggregation()) -> view().
106115
new(Name, Measure, Description, Tags, Aggregation) ->
107116
new(Name, Measure, undefined, Description, Tags, Aggregation).
108117

118+
-spec new(name(),
119+
measure_name() | oc_stat_measure:measure(),
120+
oc_stat_measure:unit(),
121+
description(),
122+
[oc_tags:key()],
123+
aggregation()) -> view().
109124
new(Name, Measure, Unit, Description, Tags, Aggregation) ->
110-
{CTags, Keys} = normalize_tags(Tags),
111125
{AggregationModule, AggregationOptions} = normalize_aggregation(Aggregation),
112126
#view{name=Name,
113127
measure=Measure,
114128
unit=Unit,
115129
description=Description,
116-
ctags=CTags,
117-
tags=Keys,
130+
tags=Tags,
118131
aggregation=AggregationModule,
119132
aggregation_options=AggregationOptions}.
120133

@@ -243,15 +256,14 @@ is_subscribed(Name) ->
243256
-spec export(view()) -> view_data().
244257
export(#view{name=Name, description=Description,
245258
unit=VUnit, measure=Measure,
246-
ctags=CTags, tags=Keys,
259+
tags=Keys,
247260
aggregation=AggregationModule,
248261
aggregation_options=AggregationOptions}) ->
249262
%% TODO: maybe just store multiplier as unit measure??
250263
MUnit = oc_stat_measure:unit(Measure),
251264
Data = AggregationModule:export(Name, AggregationOptions),
252265
#{name => Name,
253266
description => Description,
254-
ctags => CTags,
255267
tags => lists:reverse(Keys),
256268
data => oc_stat_aggregation:convert(Data, MUnit, VUnit)}.
257269

0 commit comments

Comments
 (0)