1- classdef Counter < handle
2- % Counter is a value that accumulates over time,
3- % you can think of this like an odometer on a car; it only ever goes up .
1+ classdef Counter < opentelemetry . metrics . SynchronousInstrument
2+ % Counter is a value that accumulates over time and can only increase
3+ % but not decrease .
44
55 % Copyright 2023 The MathWorks, Inc.
66
7- properties (SetAccess = immutable )
8- Name (1 ,1 ) string
9- Description (1 ,1 ) string
10- Unit (1 ,1 ) string
11- end
12-
13- properties (Access = private )
14- Proxy % Proxy object to interface C++ code
15- end
16-
177 methods (Access = {? opentelemetry .metrics .Meter })
18-
19- function obj = Counter(proxy , ctname , ctdescription , ctunit )
8+ function obj = Counter(proxy , name , description , unit )
209 % Private constructor. Use createCounter method of Meter
2110 % to create Counters.
22- obj.Proxy = proxy ;
23- obj.Name = ctname ;
24- obj.Description = ctdescription ;
25- obj.Unit = ctunit ;
11+ [email protected] (
proxy ,
name ,
description ,
unit );
2612 end
27-
2813 end
29-
14+
3015 methods
31-
3216 function add(obj , value , varargin )
33- % input value must be a numerical scalar
34- if isnumeric(value ) && isscalar(value )
35-
36- if nargin == 2
37- obj .Proxy .add(value );
38-
39- elseif isa(varargin{1 }, " dictionary" )
40- attrkeys = keys(varargin{1 });
41- attrvals = values(varargin{1 }," cell" );
42- if all(cellfun(@iscell , attrvals ))
43- attrvals = [attrvals{: }];
44- end
45- obj .Proxy .add(value ,attrkeys ,attrvals );
46-
47- else
48- attrkeys = [varargin{1 : 2 : length(varargin )}]' ;
49- attrvals = [varargin(2 : 2 : length(varargin ))]' ;
50- obj .Proxy .add(value ,attrkeys ,attrvals );
51- end
52- end
53-
17+ obj .processValue(value , varargin{: });
5418 end
55-
5619 end
57-
58-
59- end
20+ end
0 commit comments