1313 Proxy % Proxy object to interface C++ code
1414 end
1515
16- properties ( SetAccess = immutable )
17- Name (1 ,1 ) string % View name
18- Description (1 ,1 ) string % Description of view
19- InstrumentName (1 ,1 ) string % Name of the instrument this view applies to
20- InstrumentType (1 ,1 ) string % Type of instrument this view applies to
21- InstrumentUnit (1 ,1 ) string % Unit of instrument this view applies to
22- MeterName (1 ,1 ) string % Name of the meter this view applies to
23- MeterVersion (1 ,1 ) string % Version of the meter this view applies to
24- MeterSchema (1 ,1 ) string % Schema URL of the meter this view applies to
25- AllowedAttributes (1 ,: ) string % List of attribute keys that are kept. All other attributes are ignored.
26- Aggregation (1 ,1 ) string % Customized aggregation type
27- HistogramBinEdges (1 ,: ) double % Vector of customized bin edges for histogram
16+ properties
17+ Name (1 ,1 ) string = " " % View name
18+ Description (1 ,1 ) string = " " % Description of view
19+ InstrumentName (1 ,1 ) string % Name of the instrument this view applies to
20+ InstrumentType (1 ,1 ) string % Type of instrument this view applies to
21+ InstrumentUnit (1 ,1 ) string = " " % Unit of instrument this view applies to
22+ MeterName (1 ,1 ) string = " " % Name of the meter this view applies to
23+ MeterVersion (1 ,1 ) string = " " % Version of the meter this view applies to
24+ MeterSchema (1 ,1 ) string = " " % Schema URL of the meter this view applies to
25+ AllowedAttributes (1 ,: ) string % List of attribute keys that are kept. All other attributes are ignored.
26+ Aggregation (1 ,1 ) string % Customized aggregation type
27+ HistogramBinEdges (1 ,: ) double = zeros( 1 , 0 ) % Vector of customized bin edges for histogram
2828 end
2929
3030 methods
3333 % V = OPENTELEMETRY.SDK.METRICS.VIEW(PARAM1, VALUE1, PARAM2,
3434 % VALUE2, ...) creates a view object and specifies its
3535 % behavior using parameter name/value pairs. Parameters are:
36- % "Name" - Name of view. Any metric this view
36+ % "Name" - Name of view. Any metric this view
3737 % applies to will be renamed to this name.
3838 % "Description" - Description of view.
3939 % "InstrumentName" - Specifies an instrument name. This
4242 % this name.
4343 % "InstrumentType" - Specifies an instrument type. This
4444 % view will be applied to all metrics
45- % generated from all instruments of
45+ % generated from all instruments of
4646 % this type.
4747 % "InstrumentUnit" - Specifies an instrument unit. This
4848 % view will be applied to all metrics
6161 % generated from all instruments created
6262 % by meters with this schema URL.
6363 % "AllowedAttributes" - Specifies a list of attributes
64- % that will be kept. All other
64+ % that will be kept. All other
6565 % attributes will be dropped.
6666 % "Aggregation" - Change instruments to use a
67- % different aggregation beahvior.
67+ % different aggregation beahvior.
6868 % "HistogramBinEdges" - Use a different set of bins
6969 % in all histograms this view
7070 % applies to
8383 %
8484 % See also OPENTELEMETRY.SDK.METRICS.METERPROVIDER
8585 arguments
86- options.Name {mustBeTextScalar } = " "
87- options.Description {mustBeTextScalar } = " "
86+ options.Name {mustBeTextScalar }
87+ options.Description {mustBeTextScalar }
8888 options.InstrumentName {mustBeTextScalar } = " *"
8989 options.InstrumentType {mustBeTextScalar } = " counter"
90- options.InstrumentUnit {mustBeTextScalar } = " "
91- options.MeterName {mustBeTextScalar } = " "
92- options.MeterVersion {mustBeTextScalar } = " "
93- options.MeterSchema {mustBeTextScalar } = " "
94- options.AllowedAttributes {mustBeText , mustBeVector } % no default here
90+ options.InstrumentUnit {mustBeTextScalar }
91+ options.MeterName {mustBeTextScalar }
92+ options.MeterVersion {mustBeTextScalar }
93+ options.MeterSchema {mustBeTextScalar }
94+ options.AllowedAttributes {mustBeText , mustBeVector } = " * "
9595 options.Aggregation {mustBeTextScalar } = " default"
96- options.HistogramBinEdges {mustBeNumeric , mustBeVector } = zeros( 1 , 0 )
96+ options.HistogramBinEdges {mustBeNumeric , mustBeVector }
9797 end
9898
99+ obj.Proxy = libmexclass .proxy .Proxy(" Name" , " libmexclass.opentelemetry.sdk.ViewProxy" , ...
100+ " ConstructorArguments" , {});
101+
102+ if isfield(options , " Name" )
103+ obj.Name = options .Name ;
104+ end
105+ if isfield(options , " Description" )
106+ obj.Description = options .Description ;
107+ end
108+ obj.InstrumentName = options .InstrumentName ;
109+ obj.InstrumentType = options .InstrumentType ;
110+ if isfield(options , " InstrumentUnit" )
111+ obj.InstrumentUnit = options .InstrumentUnit ;
112+ end
113+ if isfield(options , " MeterName" )
114+ obj.MeterName = options .MeterName ;
115+ end
116+ if isfield(options , " MeterVersion" )
117+ obj.MeterVersion = options .MeterVersion ;
118+ end
119+ if isfield(options , " MeterSchema" )
120+ obj.MeterSchema = options .MeterSchema ;
121+ end
122+ obj.AllowedAttributes = options .AllowedAttributes ;
123+ obj.Aggregation = options .Aggregation ;
124+ if isfield(options , " HistogramBinEdges" )
125+ obj.HistogramBinEdges = options .HistogramBinEdges ;
126+ end
127+ end
128+
129+ function obj = set .Name(obj , name )
130+ arguments
131+ obj
132+ name {mustBeTextScalar }
133+ end
134+ name = string(name );
135+ obj .Proxy .setName(name ); % #ok<*MCSUP>
136+ obj.Name = name ;
137+ end
138+
139+ function obj = set .Description(obj , desc )
140+ arguments
141+ obj
142+ desc {mustBeTextScalar }
143+ end
144+ desc = string(desc );
145+ obj .Proxy .setDescription(desc );
146+ obj.Description = desc ;
147+ end
148+
149+ function obj = set .InstrumentName(obj , instname )
150+ arguments
151+ obj
152+ instname {mustBeTextScalar }
153+ end
154+ instname = string(instname );
155+ obj .Proxy .setInstrumentName(instname );
156+ obj.InstrumentName = instname ;
157+ end
158+
159+ function obj = set .InstrumentType(obj , insttype )
160+ arguments
161+ obj
162+ insttype {mustBeTextScalar }
163+ end
99164 instrument_types = [" counter" , " histogram" , " updowncounter" , ...
100165 " observablecounter" , " observableupdowncounter" , " observablegauge" ];
101- instrument_type = validatestring(options .InstrumentType , instrument_types );
166+ insttype = validatestring(insttype , instrument_types );
167+ obj .Proxy .setInstrumentType(insttype );
168+ obj.InstrumentType = insttype ;
169+ end
102170
103- aggregation_types = [" drop" , " histogram" , " lastvalue" , " sum" , " default" ];
104- aggregation_type = validatestring(options .Aggregation , aggregation_types );
105-
106- % check whether AllowedAttributes is defined
107- filter_attributes = isfield(options , " AllowedAttributes" );
108- if ~filter_attributes
109- % put some defaults here, which will be ignored since filter_attributes is false
110- options.AllowedAttributes = strings(1 ,0 );
171+ function obj = set .InstrumentUnit(obj , instunit )
172+ arguments
173+ obj
174+ instunit {mustBeTextScalar }
111175 end
176+ instunit = string(instunit );
177+ obj .Proxy .setInstrumentUnit(instunit );
178+ obj.InstrumentUnit = instunit ;
179+ end
112180
113- obj.Proxy = libmexclass .proxy .Proxy(" Name" , " libmexclass.opentelemetry.sdk.ViewProxy" , ...
114- " ConstructorArguments" , {options .Name , options .Description , options .InstrumentName , ...
115- instrument_type , options .InstrumentUnit , options .MeterName , ...
116- options .MeterVersion , options .MeterSchema , filter_attributes ,...
117- options .AllowedAttributes , aggregation_type , options .HistogramBinEdges });
118-
119- obj.Name = string(options .Name );
120- obj.Description = string(options .Description );
121- obj.InstrumentName = string(options .InstrumentName );
122- obj.InstrumentType = instrument_type ;
123- obj.InstrumentUnit = string(options .InstrumentUnit );
124- obj.MeterName = string(options .MeterName );
125- obj.MeterVersion = string(options .MeterVersion );
126- obj.MeterSchema = string(options .MeterSchema );
127- obj.AllowedAttributes = reshape(string(options .AllowedAttributes ),1 ,[]);
128- obj.Aggregation = aggregation_type ;
129- obj.HistogramBinEdges = reshape(double(options .HistogramBinEdges ),1 ,[]);
181+ function obj = set .MeterName(obj , metername )
182+ arguments
183+ obj
184+ metername {mustBeTextScalar }
185+ end
186+ metername = string(metername );
187+ obj .Proxy .setMeterName(metername )
188+ obj.MeterName = metername ;
189+ end
190+
191+ function obj = set .MeterVersion(obj , meterversion )
192+ arguments
193+ obj
194+ meterversion {mustBeTextScalar }
195+ end
196+ meterversion = string(meterversion );
197+ obj .Proxy .setMeterVersion(meterversion );
198+ obj.MeterVersion = meterversion ;
199+ end
200+
201+ function obj = set .MeterSchema(obj , meterschema )
202+ arguments
203+ obj
204+ meterschema {mustBeTextScalar }
205+ end
206+ meterschema = string(meterschema );
207+ obj .Proxy .setMeterSchema(meterschema );
208+ obj.MeterSchema = meterschema ;
209+ end
210+
211+ function obj = set .AllowedAttributes(obj , attrs )
212+ arguments
213+ obj
214+ attrs {mustBeText , mustBeVector }
215+ end
216+ attrs = reshape(string(attrs ),1 ,[]);
217+ obj .Proxy .setAllowedAttributes(attrs );
218+ obj.AllowedAttributes = attrs ;
219+ end
220+
221+ function obj = set .Aggregation(obj , agg )
222+ arguments
223+ obj
224+ agg {mustBeTextScalar }
225+ end
226+ aggregation_types = [" drop" , " histogram" , " lastvalue" , " sum" , " default" ];
227+ agg = validatestring(agg , aggregation_types );
228+ obj .Proxy .setAggregation(agg );
229+ obj.Aggregation = agg ;
230+ end
231+
232+ function obj = set .HistogramBinEdges(obj , binedges )
233+ arguments
234+ obj
235+ binedges {mustBeNumeric , mustBeVector }
236+ end
237+ binedges = reshape(double(binedges ),1 ,[]);
238+ obj .Proxy .setHistogramBinEdges(binedges );
239+ obj.HistogramBinEdges = binedges ;
130240 end
131241 end
132242end
0 commit comments