|
4 | 4 | % Copyright 2023 The MathWorks, Inc.
|
5 | 5 |
|
6 | 6 | properties (Dependent)
|
7 |
| - Entries (1,1) dictionary |
| 7 | + Entries (1,1) dictionary % Name-value pairs stored in baggage |
8 | 8 | end
|
9 | 9 |
|
10 | 10 | properties (Access=private)
|
11 |
| - Proxy |
| 11 | + Proxy % Proxy object to interface C++ code |
12 | 12 | end
|
13 | 13 |
|
14 | 14 | methods
|
15 | 15 | function obj = Baggage(entries)
|
| 16 | + % Object that stores name-value pairs, to be passed along in a context |
| 17 | + % B = OPENTELEMETRY.BAGGAGE.BAGGAGE creates an empty baggage |
| 18 | + % object. |
| 19 | + % |
| 20 | + % B = OPENTELEMETRY.BAGGAGE.BAGGAGE(ENTRIES) populate |
| 21 | + % baggage with the name-value pairs stored in dictionary |
| 22 | + % ENTRIES. The keys and values in ENTRIES must both be |
| 23 | + % strings. |
| 24 | + % |
| 25 | + % See also |
| 26 | + % OPENTELEMETRY.BAGGAGE.PROPAGATION.BAGGAGEPROPAGATOR |
16 | 27 | if nargin < 1
|
17 | 28 | entries = dictionary(strings(0,1),strings(0,1));
|
18 | 29 | end
|
|
25 | 36 | else % input is baggage entries
|
26 | 37 | if isa(entries, "dictionary")
|
27 | 38 | [keytype, valuetype] = types(entries);
|
28 |
| - % baggage keys and values must be strings |
| 39 | + % baggage keys and values must be strings |
29 | 40 | if keytype == "string" && valuetype == "string"
|
30 | 41 | obj.Proxy = libmexclass.proxy.Proxy("Name", ...
|
31 | 42 | "libmexclass.opentelemetry.BaggageProxy", ...
|
|
66 | 77 | end
|
67 | 78 |
|
68 | 79 | function obj = setEntries(obj, keys, values)
|
| 80 | + % SETENTRIES Set entry values |
| 81 | + % B = SETENTRIES(B, KEYS, VALUES) sets the values associated |
| 82 | + % with keys KEYS. Both KEYS and VALUES must be string arrays |
| 83 | + % or cell array of character vectors of the same length. If |
| 84 | + % a key is not in baggage B, the key will be added. |
| 85 | + % |
| 86 | + % See also DELETEENTRIES |
69 | 87 | arguments
|
70 | 88 | obj
|
71 | 89 | keys {mustBeVector, mustBeText}
|
|
78 | 96 | end
|
79 | 97 |
|
80 | 98 | function obj = deleteEntries(obj, keys)
|
| 99 | + % DELETEENTRIES Delete entries from baggage |
| 100 | + % B = DELETEENTRIES(B, KEYS) delete the entries associated |
| 101 | + % with keys KEYS. If a key is not in baggage B, it will be |
| 102 | + % ignored. |
| 103 | + % |
| 104 | + % See also SETENTRIES |
81 | 105 | arguments
|
82 | 106 | obj
|
83 | 107 | keys {mustBeVector, mustBeText}
|
|
86 | 110 | end
|
87 | 111 |
|
88 | 112 | function context = insertBaggage(obj, context)
|
| 113 | + % INSERTBAGGAGE Insert baggage into a context |
| 114 | + % NEWCTXT = INSERTBAGGAGE(B) inserts baggage B into the |
| 115 | + % current context and returns a new context NEWCTXT. |
| 116 | + % |
| 117 | + % NEWCTXT = INSERTBAGGAGE(B, CTXT) specifies the context to |
| 118 | + % insert into. |
| 119 | + % |
| 120 | + % See also OPENTELEMETRY.BAGGAGE.CONTEXT.EXTRACTBAGGAGE |
89 | 121 | if nargin < 2
|
90 | 122 | context = opentelemetry.context.getCurrentContext();
|
91 | 123 | end
|
|
0 commit comments