diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ad886b..d8633f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -399,15 +399,18 @@ set(COMMON_API_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/api/common/+openteleme set(TRACE_SDK_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sdk/trace/+opentelemetry) set(METRICS_SDK_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sdk/metrics/+opentelemetry) set(COMMON_SDK_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sdk/common/+opentelemetry) -set(DEFAULT_EXPORTER_MATLAB_SOURCES +set(EXPORTER_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/defaultSpanExporter.m - ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/defaultMetricExporter.m) + ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/defaultMetricExporter.m + ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpValidator.m) set(OTLP_HTTP_EXPORTER_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpSpanExporter.m - ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpMetricExporter.m) + ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpMetricExporter.m + ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpValidator.m) set(OTLP_GRPC_EXPORTER_MATLAB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m - ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m) + ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m + ${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m) set(OTLP_EXPORTERS_DIR +opentelemetry/+exporters/+otlp) @@ -419,7 +422,7 @@ install(DIRECTORY ${COMMON_API_MATLAB_SOURCES} DESTINATION .) install(DIRECTORY ${TRACE_SDK_MATLAB_SOURCES} DESTINATION .) install(DIRECTORY ${METRICS_SDK_MATLAB_SOURCES} DESTINATION .) install(DIRECTORY ${COMMON_SDK_MATLAB_SOURCES} DESTINATION .) -install(FILES ${DEFAULT_EXPORTER_MATLAB_SOURCES} DESTINATION ${OTLP_EXPORTERS_DIR}) +install(FILES ${EXPORTER_MATLAB_SOURCES} DESTINATION ${OTLP_EXPORTERS_DIR}) if(WITH_OTLP_HTTP) install(FILES ${OTLP_HTTP_EXPORTER_MATLAB_SOURCES} DESTINATION ${OTLP_EXPORTERS_DIR}) endif() diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m index 5d195fd..4d3a250 100644 --- a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m @@ -12,7 +12,10 @@ CertificateString (1,1) string = "" % In-memory string representation of .pem file for SSL encryption Timeout (1,1) duration = seconds(10) % Maximum time above which exports will abort HttpHeaders (1,1) dictionary = dictionary(string.empty, string.empty) % Additional HTTP headers - PreferredAggregationTemporality (1,1) string = "cumulative" % Preferred Aggregation Temporality + end + + properties (Constant) + Validator = opentelemetry.exporters.otlp.OtlpGrpcValidator end methods @@ -60,66 +63,39 @@ end function obj = set.Endpoint(obj, ep) - if ~(isStringScalar(ep) || (ischar(ep) && isrow(ep))) - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:EndpointNotScalarText", "Endpoint must be a scalar string."); - end - ep = string(ep); + ep = obj.Validator.validateEndpoint(ep); obj.Proxy.setEndpoint(ep); obj.Endpoint = ep; end function obj = set.UseCredentials(obj, uc) - if ~((islogical(uc) || isnumeric(uc)) && isscalar(uc)) - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:UseCredentialsNotScalarLogical", "UseCredentials must be a scalar logical.") - end - uc = logical(uc); + uc = obj.Validator.validateUseCredentials(uc); obj.Proxy.setUseCredentials(uc); obj.UseCredentials = uc; end function obj = set.CertificatePath(obj, certpath) - if ~(isStringScalar(certpath) || (ischar(certpath) && isrow(certpath))) - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:CertificatePathNotScalarText", "CertificatePath must be a scalar string."); - end - certpath = string(certpath); + certpath = obj.Validator.validateCertificatePath(certpath); obj.Proxy.setCertificatePath(certpath); obj.CertificatePath = certpath; end function obj = set.CertificateString(obj, certstr) - if ~(isStringScalar(certstr) || (ischar(certstr) && isrow(certstr))) - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:CertificateStringNotScalarText", "CertificateString must be a scalar string."); - end - certstr = string(certstr); + certstr = obj.Validator.validateCertificateString(certstr); obj.Proxy.setCertificateString(certstr); obj.CertificateString = certstr; end function obj = set.Timeout(obj, timeout) - if ~(isduration(timeout) && isscalar(timeout)) - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:TimeoutNotScalarDuration", "Timeout must be a scalar duration."); - end + obj.Validator.validateTimeout(timeout); obj.Proxy.setTimeout(milliseconds(timeout)); obj.Timeout = timeout; end function obj = set.HttpHeaders(obj, httpheaders) - if ~isa(httpheaders, "dictionary") - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); - end - headerkeys = keys(httpheaders); - headervalues = values(httpheaders); - if ~isstring(headervalues) - error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") - end + [headerkeys, headervalues] = obj.Validator.validateHttpHeaders(httpheaders); obj.Proxy.setHttpHeaders(headerkeys, headervalues); obj.HttpHeaders = httpheaders; end - - function obj = set.PreferredAggregationTemporality(obj, temporality) - temporality = validatestring(temporality, ["cumulative", "delta"]); - obj.Proxy.setTemporality(temporality); - obj.PreferredAggregationTemporality = temporality; - end end end diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m index bcf2bb6..1e43f90 100644 --- a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m @@ -14,6 +14,10 @@ HttpHeaders (1,1) dictionary = dictionary(string.empty, string.empty) % Additional HTTP headers end + properties (Constant) + Validator = opentelemetry.exporters.otlp.OtlpGrpcValidator + end + methods function obj = OtlpGrpcSpanExporter(optionnames, optionvalues) % OtlpGrpcSpanExporter exports spans in OpenTelemetry Protocol format via gRPC. @@ -56,58 +60,37 @@ end function obj = set.Endpoint(obj, ep) - if ~(isStringScalar(ep) || (ischar(ep) && isrow(ep))) - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:EndpointNotScalarText", "Endpoint must be a scalar string."); - end - ep = string(ep); + ep = obj.Validator.validateEndpoint(ep); obj.Proxy.setEndpoint(ep); obj.Endpoint = ep; end function obj = set.UseCredentials(obj, uc) - if ~((islogical(uc) || isnumeric(uc)) && isscalar(uc)) - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:UseCredentialsNotScalarLogical", "UseCredentials must be a scalar logical.") - end - uc = logical(uc); + uc = obj.Validator.validateUseCredentials(uc); obj.Proxy.setUseCredentials(uc); obj.UseCredentials = uc; end function obj = set.CertificatePath(obj, certpath) - if ~(isStringScalar(certpath) || (ischar(certpath) && isrow(certpath))) - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:CertificatePathNotScalarText", "CertificatePath must be a scalar string."); - end - certpath = string(certpath); + certpath = obj.Validator.validateCertificatePath(certpath); obj.Proxy.setCertificatePath(certpath); obj.CertificatePath = certpath; end function obj = set.CertificateString(obj, certstr) - if ~(isStringScalar(certstr) || (ischar(certstr) && isrow(certstr))) - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:CertificateStringNotScalarText", "CertificateString must be a scalar string."); - end - certstr = string(certstr); + certstr = obj.Validator.validateCertificateString(certstr); obj.Proxy.setCertificateString(certstr); obj.CertificateString = certstr; end function obj = set.Timeout(obj, timeout) - if ~(isduration(timeout) && isscalar(timeout)) - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:TimeoutNotScalarDuration", "Timeout must be a scalar duration."); - end + obj.Validator.validateTimeout(timeout); obj.Proxy.setTimeout(milliseconds(timeout)); obj.Timeout = timeout; end function obj = set.HttpHeaders(obj, httpheaders) - if ~isa(httpheaders, "dictionary") - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); - end - headerkeys = keys(httpheaders); - headervalues = values(httpheaders); - if ~isstring(headervalues) - error("opentelemetry:exporters:otlp:OtlpGrpcSpanExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") - end + [headerkeys, headervalues] = obj.Validator.validateHttpHeaders(httpheaders); obj.Proxy.setHttpHeaders(headerkeys, headervalues); obj.HttpHeaders = httpheaders; end diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m new file mode 100644 index 0000000..05b6d02 --- /dev/null +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m @@ -0,0 +1,32 @@ +classdef OtlpGrpcValidator < opentelemetry.exporters.otlp.OtlpValidator +% OtlpGrpcValidator Validate options inputs for OtlpGrpcSpanExporter and +% OtlpGrpcMetricExporter + +% Copyright 2023 The MathWorks, Inc. + + methods (Static) + function uc = validateUseCredentials(uc) + if ~((islogical(uc) || isnumeric(uc)) && isscalar(uc)) + error("opentelemetry:exporters:otlp:OtlpGrpcValidator:UseCredentialsNotScalarLogical", ... + "UseCredentials must be a scalar logical.") + end + uc = logical(uc); + end + + function certpath = validateCertificatePath(certpath) + if ~(isStringScalar(certpath) || (ischar(certpath) && isrow(certpath))) + error("opentelemetry:exporters:otlp:OtlpGrpcValidator:CertificatePathNotScalarText", ... + "CertificatePath must be a scalar string."); + end + certpath = string(certpath); + end + + function certstr = validateCertificateString(certstr) + if ~(isStringScalar(certstr) || (ischar(certstr) && isrow(certstr))) + error("opentelemetry:exporters:otlp:OtlpGrpcValidator:CertificateStringNotScalarText", ... + "CertificateString must be a scalar string."); + end + certstr = string(certstr); + end + end +end diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpMetricExporter.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpMetricExporter.m index 490c468..7890c9c 100644 --- a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpMetricExporter.m +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpMetricExporter.m @@ -12,7 +12,10 @@ UseJsonName (1,1) logical = false % Whether to use JSON name of protobuf field to set the key of JSON Timeout (1,1) duration = seconds(10) % Maximum time above which exports will abort HttpHeaders (1,1) dictionary = dictionary(string.empty, string.empty) % Additional HTTP headers - PreferredAggregationTemporality (1,1) string = "cumulative" % Preferred Aggregation Temporality + end + + properties (Constant) + Validator = opentelemetry.exporters.otlp.OtlpHttpValidator end methods @@ -60,60 +63,39 @@ end function obj = set.Endpoint(obj, ep) - if ~(isStringScalar(ep) || (ischar(ep) && isrow(ep))) - error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:EndpointNotScalarText", "Endpoint must be a scalar string."); - end - ep = string(ep); + ep = obj.Validator.validateEndpoint(ep); obj.Proxy.setEndpoint(ep); obj.Endpoint = ep; end function obj = set.Format(obj, newformat) - newformat = validatestring(newformat, ["JSON", "binary"]); + newformat = obj.Validator.validateFormat(newformat); obj.Proxy.setFormat(newformat); obj.Format = newformat; end function obj = set.JsonBytesMapping(obj, jbm) - jbm = validatestring(jbm, ["hex", "hexId", "base64"]); + jbm = obj.Validator.validateJsonBytesMapping(jbm); obj.Proxy.setJsonBytesMapping(jbm); obj.JsonBytesMapping = jbm; end function obj = set.UseJsonName(obj, ujn) - if ~((islogical(ujn) || isnumeric(ujn)) && isscalar(ujn)) - error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:UseJsonNameNotScalarLogical", "UseJsonName must be a scalar logical.") - end - ujn = logical(ujn); + ujn = obj.Validator.validateUseJsonName(ujn); obj.Proxy.setUseJsonName(ujn); obj.UseJsonName = ujn; end function obj = set.Timeout(obj, timeout) - if ~(isduration(timeout) && isscalar(timeout)) - error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:TimeoutNotScalarDuration", "Timeout must be a scalar duration."); - end + obj.Validator.validateTimeout(timeout); obj.Proxy.setTimeout(milliseconds(timeout)); obj.Timeout = timeout; end function obj = set.HttpHeaders(obj, httpheaders) - if ~isa(httpheaders, "dictionary") - error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); - end - headerkeys = keys(httpheaders); - headervalues = values(httpheaders); - if ~isstring(headervalues) - error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") - end + [headerkeys, headervalues] = obj.Validator.validateHttpHeaders(httpheaders); obj.Proxy.setHttpHeaders(headerkeys, headervalues); obj.HttpHeaders = httpheaders; end - - function obj = set.PreferredAggregationTemporality(obj, temporality) - temporality = validatestring(temporality, ["cumulative", "delta"]); - obj.Proxy.setTemporality(temporality); - obj.PreferredAggregationTemporality = temporality; - end end end diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpSpanExporter.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpSpanExporter.m index cf79565..9c10787 100644 --- a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpSpanExporter.m +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpSpanExporter.m @@ -14,6 +14,10 @@ HttpHeaders (1,1) dictionary = dictionary(string.empty, string.empty) % Additional HTTP headers end + properties (Constant) + Validator = opentelemetry.exporters.otlp.OtlpHttpValidator + end + methods function obj = OtlpHttpSpanExporter(optionnames, optionvalues) % OtlpHttpSpanExporter exports spans in OpenTelemetry Protocol format via HTTP. @@ -56,52 +60,37 @@ end function obj = set.Endpoint(obj, ep) - if ~(isStringScalar(ep) || (ischar(ep) && isrow(ep))) - error("opentelemetry:exporters:otlp:OtlpHttpSpanExporter:EndpointNotScalarText", "Endpoint must be a scalar string."); - end - ep = string(ep); + ep = obj.Validator.validateEndpoint(ep); obj.Proxy.setEndpoint(ep); obj.Endpoint = ep; end function obj = set.Format(obj, newformat) - newformat = validatestring(newformat, ["JSON", "binary"]); + newformat = obj.Validator.validateFormat(newformat); obj.Proxy.setFormat(newformat); obj.Format = newformat; end function obj = set.JsonBytesMapping(obj, jbm) - jbm = validatestring(jbm, ["hex", "hexId", "base64"]); + jbm = obj.Validator.validateJsonBytesMapping(jbm); obj.Proxy.setJsonBytesMapping(jbm); obj.JsonBytesMapping = jbm; end function obj = set.UseJsonName(obj, ujn) - if ~((islogical(ujn) || isnumeric(ujn)) && isscalar(ujn)) - error("opentelemetry:exporters:otlp:OtlpHttpSpanExporter:UseJsonNameNotScalarLogical", "UseJsonName must be a scalar logical.") - end - ujn = logical(ujn); + ujn = obj.Validator.validateUseJsonName(ujn); obj.Proxy.setUseJsonName(ujn); obj.UseJsonName = ujn; end function obj = set.Timeout(obj, timeout) - if ~(isduration(timeout) && isscalar(timeout)) - error("opentelemetry:exporters:otlp:OtlpHttpSpanExporter:TimeoutNotScalarDuration", "Timeout must be a scalar duration."); - end + obj.Validator.validateTimeout(timeout); obj.Proxy.setTimeout(milliseconds(timeout)); obj.Timeout = timeout; end function obj = set.HttpHeaders(obj, httpheaders) - if ~isa(httpheaders, "dictionary") - error("opentelemetry:exporters:otlp:OtlpHttpSpanExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); - end - headerkeys = keys(httpheaders); - headervalues = values(httpheaders); - if ~isstring(headervalues) - error("opentelemetry:exporters:otlp:OtlpHttpSpanExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") - end + [headerkeys, headervalues] = obj.Validator.validateHttpHeaders(httpheaders); obj.Proxy.setHttpHeaders(headerkeys, headervalues); obj.HttpHeaders = httpheaders; end diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpValidator.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpValidator.m new file mode 100644 index 0000000..17ba494 --- /dev/null +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpValidator.m @@ -0,0 +1,23 @@ +classdef OtlpHttpValidator < opentelemetry.exporters.otlp.OtlpValidator +% OtlpHttpValidator Validate options inputs for OtlpHttpSpanExporter and +% OtlpHttpMetricExporter + +% Copyright 2023 The MathWorks, Inc. + + methods (Static) + function newformat = validateFormat(newformat) + newformat = validatestring(newformat, ["JSON", "binary"]); + end + + function jbm = validateJsonBytesMapping(jbm) + jbm = validatestring(jbm, ["hex", "hexId", "base64"]); + end + + function ujn = validateUseJsonName(ujn) + if ~((islogical(ujn) || isnumeric(ujn)) && isscalar(ujn)) + error("opentelemetry:exporters:otlp:OtlpHttpValidator:UseJsonNameNotScalarLogical", "UseJsonName must be a scalar logical.") + end + ujn = logical(ujn); + end + end +end diff --git a/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpValidator.m b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpValidator.m new file mode 100644 index 0000000..db13f2e --- /dev/null +++ b/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpValidator.m @@ -0,0 +1,35 @@ +classdef OtlpValidator +% OtlpValidator Validate export options + +% Copyright 2023 The MathWorks, Inc. + + methods (Static) + function ep = validateEndpoint(ep) + if ~(isStringScalar(ep) || (ischar(ep) && isrow(ep))) + error("opentelemetry:exporters:otlp:OtlpValidator:EndpointNotScalarText", ... + "Endpoint must be a scalar string."); + end + ep = string(ep); + end + + function validateTimeout(timeout) + if ~(isduration(timeout) && isscalar(timeout)) + error("opentelemetry:exporters:otlp:OtlpValidator:TimeoutNotScalarDuration", ... + "Timeout must be a scalar duration."); + end + end + + function [headerkeys, headervalues] = validateHttpHeaders(httpheaders) + if ~isa(httpheaders, "dictionary") + error("opentelemetry:exporters:otlp:OtlpValidator:HttpHeadersNotDictionary", ... + "HttpHeaders input must be a dictionary."); + end + headerkeys = keys(httpheaders); + headervalues = values(httpheaders); + if ~isstring(headervalues) + error("opentelemetry:exporters:otlp:OtlpValidator:HttpHeadersNonStringValues", ... + "HttpHeaders dictionary values must be strings.") + end + end + end +end diff --git a/exporters/otlp/include/opentelemetry-matlab/exporters/otlp/OtlpHttpSpanExporterProxy.h b/exporters/otlp/include/opentelemetry-matlab/exporters/otlp/OtlpHttpSpanExporterProxy.h index f735635..c2b0c0c 100644 --- a/exporters/otlp/include/opentelemetry-matlab/exporters/otlp/OtlpHttpSpanExporterProxy.h +++ b/exporters/otlp/include/opentelemetry-matlab/exporters/otlp/OtlpHttpSpanExporterProxy.h @@ -29,8 +29,6 @@ class OtlpHttpSpanExporterProxy: public libmexclass::opentelemetry::sdk::SpanExp std::unique_ptr getInstance() override; - void getDefaultOptionValues(libmexclass::proxy::method::Context& context); - void setEndpoint(libmexclass::proxy::method::Context& context); void setFormat(libmexclass::proxy::method::Context& context); diff --git a/sdk/metrics/+opentelemetry/+sdk/+metrics/MetricExporter.m b/sdk/metrics/+opentelemetry/+sdk/+metrics/MetricExporter.m index 389d035..8b3de57 100644 --- a/sdk/metrics/+opentelemetry/+sdk/+metrics/MetricExporter.m +++ b/sdk/metrics/+opentelemetry/+sdk/+metrics/MetricExporter.m @@ -3,6 +3,10 @@ % Copyright 2023 The MathWorks, Inc. + properties + PreferredAggregationTemporality (1,1) string = "cumulative" % Preferred Aggregation Temporality + end + properties (Access={?opentelemetry.sdk.metrics.PeriodicExportingMetricReader, ... ?opentelemetry.exporters.otlp.OtlpHttpMetricExporter, ... ?opentelemetry.exporters.otlp.OtlpGrpcMetricExporter}) @@ -15,9 +19,14 @@ obj.Proxy = libmexclass.proxy.Proxy("Name", proxyname, ... "ConstructorArguments", varargin); end + end - function varargout = getDefaultOptionValues(obj) - [varargout{1:nargout}] = obj.Proxy.getDefaultOptionValues(); + methods + function obj = set.PreferredAggregationTemporality(obj, temporality) + temporality = validatestring(temporality, ["cumulative", "delta"]); + obj.Proxy.setTemporality(temporality); + obj.PreferredAggregationTemporality = temporality; end + end end diff --git a/sdk/trace/+opentelemetry/+sdk/+trace/SpanExporter.m b/sdk/trace/+opentelemetry/+sdk/+trace/SpanExporter.m index 846e518..cf0e4df 100644 --- a/sdk/trace/+opentelemetry/+sdk/+trace/SpanExporter.m +++ b/sdk/trace/+opentelemetry/+sdk/+trace/SpanExporter.m @@ -15,9 +15,5 @@ obj.Proxy = libmexclass.proxy.Proxy("Name", proxyname, ... "ConstructorArguments", varargin); end - - function varargout = getDefaultOptionValues(obj) - [varargout{1:nargout}] = obj.Proxy.getDefaultOptionValues(); - end end end