|
12 | 12 | CertificateString (1,1) string = "" % In-memory string representation of .pem file for SSL encryption |
13 | 13 | Timeout (1,1) duration = seconds(10) % Maximum time above which exports will abort |
14 | 14 | HttpHeaders (1,1) dictionary = dictionary(string.empty, string.empty) % Additional HTTP headers |
15 | | - PreferredAggregationTemporality (1,1) string = "cumulative" % Preferred Aggregation Temporality |
| 15 | + end |
| 16 | + |
| 17 | + properties (Constant) |
| 18 | + Validator = opentelemetry.exporters.otlp.OtlpGrpcValidator |
16 | 19 | end |
17 | 20 |
|
18 | 21 | methods |
|
60 | 63 | end |
61 | 64 |
|
62 | 65 | function obj = set.Endpoint(obj, ep) |
63 | | - if ~(isStringScalar(ep) || (ischar(ep) && isrow(ep))) |
64 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:EndpointNotScalarText", "Endpoint must be a scalar string."); |
65 | | - end |
66 | | - ep = string(ep); |
| 66 | + ep = obj.Validator.validateEndpoint(ep); |
67 | 67 | obj.Proxy.setEndpoint(ep); |
68 | 68 | obj.Endpoint = ep; |
69 | 69 | end |
70 | 70 |
|
71 | 71 | function obj = set.UseCredentials(obj, uc) |
72 | | - if ~((islogical(uc) || isnumeric(uc)) && isscalar(uc)) |
73 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:UseCredentialsNotScalarLogical", "UseCredentials must be a scalar logical.") |
74 | | - end |
75 | | - uc = logical(uc); |
| 72 | + uc = obj.Validator.validateUseCredentials(uc); |
76 | 73 | obj.Proxy.setUseCredentials(uc); |
77 | 74 | obj.UseCredentials = uc; |
78 | 75 | end |
79 | 76 |
|
80 | 77 | function obj = set.CertificatePath(obj, certpath) |
81 | | - if ~(isStringScalar(certpath) || (ischar(certpath) && isrow(certpath))) |
82 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:CertificatePathNotScalarText", "CertificatePath must be a scalar string."); |
83 | | - end |
84 | | - certpath = string(certpath); |
| 78 | + certpath = obj.Validator.validateCertificatePath(certpath); |
85 | 79 | obj.Proxy.setCertificatePath(certpath); |
86 | 80 | obj.CertificatePath = certpath; |
87 | 81 | end |
88 | 82 |
|
89 | 83 | function obj = set.CertificateString(obj, certstr) |
90 | | - if ~(isStringScalar(certstr) || (ischar(certstr) && isrow(certstr))) |
91 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:CertificateStringNotScalarText", "CertificateString must be a scalar string."); |
92 | | - end |
93 | | - certstr = string(certstr); |
| 84 | + certstr = obj.Validator.validateCertificateString(certstr); |
94 | 85 | obj.Proxy.setCertificateString(certstr); |
95 | 86 | obj.CertificateString = certstr; |
96 | 87 | end |
97 | 88 |
|
98 | 89 | function obj = set.Timeout(obj, timeout) |
99 | | - if ~(isduration(timeout) && isscalar(timeout)) |
100 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:TimeoutNotScalarDuration", "Timeout must be a scalar duration."); |
101 | | - end |
| 90 | + obj.Validator.validateTimeout(timeout); |
102 | 91 | obj.Proxy.setTimeout(milliseconds(timeout)); |
103 | 92 | obj.Timeout = timeout; |
104 | 93 | end |
105 | 94 |
|
106 | 95 | function obj = set.HttpHeaders(obj, httpheaders) |
107 | | - if ~isa(httpheaders, "dictionary") |
108 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); |
109 | | - end |
110 | | - headerkeys = keys(httpheaders); |
111 | | - headervalues = values(httpheaders); |
112 | | - if ~isstring(headervalues) |
113 | | - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") |
114 | | - end |
| 96 | + [headerkeys, headervalues] = obj.Validator.validateHttpHeaders(httpheaders); |
115 | 97 | obj.Proxy.setHttpHeaders(headerkeys, headervalues); |
116 | 98 | obj.HttpHeaders = httpheaders; |
117 | 99 | end |
118 | | - |
119 | | - function obj = set.PreferredAggregationTemporality(obj, temporality) |
120 | | - temporality = validatestring(temporality, ["cumulative", "delta"]); |
121 | | - obj.Proxy.setTemporality(temporality); |
122 | | - obj.PreferredAggregationTemporality = temporality; |
123 | | - end |
124 | 100 | end |
125 | 101 | end |
0 commit comments