File tree Expand file tree Collapse file tree 12 files changed +198
-226
lines changed
include/opentelemetry-matlab/metrics Expand file tree Collapse file tree 12 files changed +198
-226
lines changed Original file line number Diff line number Diff line change 1414
1515 methods
1616 function add(obj , value , varargin )
17- % input value must be a numerical scalar
18- if isnumeric(value ) && isscalar(value )
19- if nargin == 2
20- obj .Proxy .add(value );
21- elseif isa(varargin{1 }, " dictionary" )
22- attrkeys = keys(varargin{1 });
23- attrvals = values(varargin{1 }," cell" );
24- if all(cellfun(@iscell , attrvals ))
25- attrvals = [attrvals{: }];
26- end
27- obj .Proxy .add(value , attrkeys , attrvals );
28- else
29- attrkeys = [varargin{1 : 2 : length(varargin )}]' ;
30- attrvals = [varargin(2 : 2 : length(varargin ))]' ;
31- obj .Proxy .add(value , attrkeys , attrvals );
32- end
33- end
17+ obj .processValue(value , varargin{: });
3418 end
3519 end
3620end
Original file line number Diff line number Diff line change 1313
1414 methods
1515 function record(obj , value , varargin )
16- % input value must be a numerical scalar
17- if isnumeric(value ) && isscalar(value )
18- if nargin == 2
19- obj .Proxy .record(value );
20- elseif isa(varargin{1 }, " dictionary" )
21- attrkeys = keys(varargin{1 });
22- attrvals = values(varargin{1 }," cell" );
23- if all(cellfun(@iscell , attrvals ))
24- attrvals = [attrvals{: }];
25- end
26- obj .Proxy .record(value , attrkeys , attrvals );
27- else
28- attrkeys = [varargin{1 : 2 : length(varargin )}]' ;
29- attrvals = [varargin(2 : 2 : length(varargin ))]' ;
30- obj .Proxy .record(value , attrkeys , attrvals );
31- end
32- end
16+ obj .processValue(value , varargin{: });
3317 end
3418 end
3519end
Original file line number Diff line number Diff line change 99 Unit (1 ,1 ) string
1010 end
1111
12- properties (Access = protected )
12+ properties (Access = private )
1313 Proxy % Proxy object to interface C++ code
1414 end
1515
2020 obj.Description = description ;
2121 obj.Unit = unit ;
2222 end
23+
24+ function processValue(obj , value , varargin )
25+ % input value must be a numerical real scalar
26+ if isnumeric(value ) && isscalar(value ) && isreal(value )
27+ if nargin == 2
28+ obj .Proxy .processValue(value );
29+ elseif isa(varargin{1 }, " dictionary" )
30+ attrkeys = keys(varargin{1 });
31+ attrvals = values(varargin{1 }," cell" );
32+ if all(cellfun(@iscell , attrvals ))
33+ attrvals = [attrvals{: }];
34+ end
35+ obj .Proxy .processValue(value , attrkeys , attrvals );
36+ else
37+ attrkeys = [varargin{1 : 2 : length(varargin )}]' ;
38+ attrvals = [varargin(2 : 2 : length(varargin ))]' ;
39+ obj .Proxy .processValue(value , attrkeys , attrvals );
40+ end
41+ end
42+ end
2343 end
2444end
Original file line number Diff line number Diff line change 1313
1414 methods
1515 function add(obj , value , varargin )
16- % input value must be a numerical scalar
17- if isnumeric(value ) && isscalar(value )
18- if nargin == 2
19- obj .Proxy .add(value );
20- elseif isa(varargin{1 }, " dictionary" )
21- attrkeys = keys(varargin{1 });
22- attrvals = values(varargin{1 }," cell" );
23- if all(cellfun(@iscell , attrvals ))
24- attrvals = [attrvals{: }];
25- end
26- obj .Proxy .add(value , attrkeys , attrvals );
27- else
28- attrkeys = [varargin{1 : 2 : length(varargin )}]' ;
29- attrvals = [varargin(2 : 2 : length(varargin ))]' ;
30- obj .Proxy .add(value , attrkeys , attrvals );
31- end
32- end
16+ obj .processValue(value , varargin{: });
3317 end
3418 end
3519end
Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ namespace libmexclass::opentelemetry {
1818class CounterProxy : public libmexclass ::proxy::Proxy {
1919 public:
2020 CounterProxy (nostd::shared_ptr<metrics_api::Counter<double > > ct) : CppCounter(ct) {
21- REGISTER_METHOD (CounterProxy, add );
21+ REGISTER_METHOD (CounterProxy, processValue );
2222 }
2323
24- void add (libmexclass::proxy::method::Context& context);
24+ void processValue (libmexclass::proxy::method::Context& context);
2525
2626 private:
2727
Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ namespace libmexclass::opentelemetry {
2121class HistogramProxy : public libmexclass ::proxy::Proxy {
2222 public:
2323 HistogramProxy (nostd::shared_ptr<metrics_api::Histogram<double > > hist) : CppHistogram(hist) {
24- REGISTER_METHOD (HistogramProxy, record );
24+ REGISTER_METHOD (HistogramProxy, processValue );
2525 }
2626
27- void record (libmexclass::proxy::method::Context& context);
27+ void processValue (libmexclass::proxy::method::Context& context);
2828
2929 private:
3030
Original file line number Diff line number Diff line change @@ -18,10 +18,10 @@ namespace libmexclass::opentelemetry {
1818class UpDownCounterProxy : public libmexclass ::proxy::Proxy {
1919 public:
2020 UpDownCounterProxy (nostd::shared_ptr<metrics_api::UpDownCounter<double > > ct) : CppUpDownCounter(ct) {
21- REGISTER_METHOD (UpDownCounterProxy, add );
21+ REGISTER_METHOD (UpDownCounterProxy, processValue );
2222 }
2323
24- void add (libmexclass::proxy::method::Context& context);
24+ void processValue (libmexclass::proxy::method::Context& context);
2525
2626 private:
2727
Original file line number Diff line number Diff line change 1212namespace libmexclass ::opentelemetry {
1313
1414
15- void CounterProxy::add (libmexclass::proxy::method::Context& context){
15+ void CounterProxy::processValue (libmexclass::proxy::method::Context& context){
1616
1717 matlab::data::Array value_mda = context.inputs [0 ];
1818 double value = static_cast <double >(value_mda[0 ]);
Original file line number Diff line number Diff line change 1212namespace libmexclass ::opentelemetry {
1313
1414
15- void HistogramProxy::record (libmexclass::proxy::method::Context& context){
15+ void HistogramProxy::processValue (libmexclass::proxy::method::Context& context){
1616 // Get value
1717 matlab::data::Array value_mda = context.inputs [0 ];
1818 double value = static_cast <double >(value_mda[0 ]);
Original file line number Diff line number Diff line change 1212namespace libmexclass ::opentelemetry {
1313
1414
15- void UpDownCounterProxy::add (libmexclass::proxy::method::Context& context){
15+ void UpDownCounterProxy::processValue (libmexclass::proxy::method::Context& context){
1616
1717 matlab::data::Array value_mda = context.inputs [0 ];
1818 double value = static_cast <double >(value_mda[0 ]);
You can’t perform that action at this time.
0 commit comments