-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
223 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,13 @@ | |
% Copyright 2023 The MathWorks, Inc. | ||
|
||
properties (SetAccess=immutable) | ||
Endpoint (1,1) string % Export destination | ||
UseCredentials (1,1) logical % Whether to use SSL credentials | ||
CertificatePath (1,1) string % Path to .pem file for SSL encryption | ||
CertificateString (1,1) string % In-memory string representation of .pem file for SSL encryption | ||
Timeout (1,1) duration % Maximum time above which exports will abort | ||
HttpHeaders (1,1) dictionary % Additional HTTP headers | ||
Endpoint (1,1) string % Export destination | ||
UseCredentials (1,1) logical % Whether to use SSL credentials | ||
CertificatePath (1,1) string % Path to .pem file for SSL encryption | ||
CertificateString (1,1) string % In-memory string representation of .pem file for SSL encryption | ||
Timeout (1,1) duration % Maximum time above which exports will abort | ||
HttpHeaders (1,1) dictionary % Additional HTTP headers | ||
PreferredAggregationTemporality (1,1) string % Preferred Aggregation Temporality | ||
end | ||
|
||
methods | ||
|
@@ -44,7 +45,7 @@ | |
end | ||
|
||
validnames = ["Endpoint", "UseCredentials ", "CertificatePath", ... | ||
"CertificateString", "Timeout", "HttpHeaders"]; | ||
"CertificateString", "Timeout", "HttpHeaders", "PreferredAggregationTemporality"]; | ||
% set default values to empty or negative | ||
endpoint = ""; | ||
usessl = false; | ||
|
@@ -53,6 +54,7 @@ | |
timeout_millis = -1; | ||
headerkeys = string.empty(); | ||
headervalues = string.empty(); | ||
temporality = ""; | ||
for i = 1:length(optionnames) | ||
namei = validatestring(optionnames{i}, validnames); | ||
valuei = optionvalues{i}; | ||
|
@@ -82,7 +84,7 @@ | |
end | ||
timeout = valuei; | ||
timeout_millis = milliseconds(timeout); | ||
else % HttpHeaders | ||
elseif strcmp(namei, "HttpHeaders") % HttpHeaders | ||
if ~isa(valuei, "dictionary") | ||
error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); | ||
end | ||
|
@@ -92,16 +94,18 @@ | |
if ~isstring(headervalues) | ||
error("opentelemetry:exporters:otlp:OtlpGrpcMetricExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") | ||
end | ||
elseif strcmp(namei, "PreferredAggregationTemporality") | ||
temporality = validatestring(valuei, ["Cumulative", "Delta"]); | ||
end | ||
end | ||
|
||
obj = [email protected](... | ||
"libmexclass.opentelemetry.exporters.OtlpGrpcMetricExporterProxy", ... | ||
endpoint, usessl, certificatepath, certificatestring, ... | ||
timeout_millis, headerkeys, headervalues); | ||
timeout_millis, headerkeys, headervalues, temporality); | ||
|
||
% populate immutable properties | ||
[defaultendpoint, defaultcertpath, defaultcertstring, defaultmillis] = ... | ||
[defaultendpoint, defaultcertpath, defaultcertstring, defaultmillis, defaulttemporality] = ... | ||
getDefaultOptionValues(obj); | ||
if endpoint == "" % not specified, use default value | ||
obj.Endpoint = defaultendpoint; | ||
|
@@ -129,7 +133,11 @@ | |
else | ||
obj.HttpHeaders = httpheaders; | ||
end | ||
|
||
if temporality == "" | ||
obj.PreferredAggregationTemporality = defaulttemporality; | ||
else | ||
obj.PreferredAggregationTemporality = temporality; | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,45 +6,25 @@ | |
% Copyright 2023 The MathWorks, Inc. | ||
|
||
properties (SetAccess=immutable) | ||
Endpoint (1,1) string % Export destination | ||
Format (1,1) string % Data format, JSON or binary | ||
JsonBytesMapping (1,1) string % What to convert JSON bytes to | ||
UseJsonName (1,1) logical % Whether to use JSON name of protobuf field to set the key of JSON | ||
Timeout (1,1) duration % Maximum time above which exports will abort | ||
HttpHeaders (1,1) dictionary % Additional HTTP headers | ||
Endpoint (1,1) string % Export destination | ||
Format (1,1) string % Data format, JSON or binary | ||
JsonBytesMapping (1,1) string % What to convert JSON bytes to | ||
UseJsonName (1,1) logical % Whether to use JSON name of protobuf field to set the key of JSON | ||
Timeout (1,1) duration % Maximum time above which exports will abort | ||
HttpHeaders (1,1) dictionary % Additional HTTP headers | ||
PreferredAggregationTemporality (1,1) string % Preferred Aggregation Temporality | ||
end | ||
|
||
methods | ||
function obj = OtlpHttpMetricExporter(optionnames, optionvalues) | ||
% OtlpHttpMetricExporter exports Metrics in OpenTelemetry Protocol format via HTTP. | ||
% EXP = OPENTELEMETRY.EXPORTERS.OTLP.OTLPHTTPMetricEXPORTER | ||
% creates an exporter that uses default configurations. | ||
% | ||
% EXP = | ||
% OPENTELEMETRY.EXPORTERS.OTLP.OTLPHTTPMetricEXPORTER(PARAM1, | ||
% VALUE1, PARAM2, VALUE2, ...) specifies optional parameter | ||
% name/value pairs. Parameters are: | ||
% "Endpoint" - Endpoint to export to | ||
% "Format" - Data format: "JSON" (default) or "binary" | ||
% "JsonBytesMapping" - What to convert JSON bytes to. Supported | ||
% values are "hex", "hexId" (default), and | ||
% "base64". Default "hexId" | ||
% converts to base 64 except for IDs | ||
% which are converted to hexadecimals. | ||
% "UseJsonName" - Whether to use JSON name of protobuf | ||
% field to set the key of JSON | ||
% "Timeout" - Maximum time above which exports | ||
% will abort | ||
% "HTTPHeaders" - Additional HTTP Headers | ||
% | ||
% See also OPENTELEMETRY.EXPORTERS.OTLP.OTLPGRPCMetricEXPORTER | ||
|
||
arguments (Repeating) | ||
optionnames (1,:) {mustBeTextScalar} | ||
optionvalues | ||
end | ||
|
||
validnames = ["Endpoint", "Format", "JsonBytesMapping", ... | ||
"UseJsonName", "Timeout", "HttpHeaders"]; | ||
"UseJsonName", "Timeout", "HttpHeaders", "PreferredAggregationTemporality"]; | ||
% set default values to empty or negative | ||
endpoint = ""; | ||
dataformat = ""; | ||
|
@@ -53,6 +33,7 @@ | |
timeout_millis = -1; | ||
headerkeys = string.empty(); | ||
headervalues = string.empty(); | ||
temporality = ""; | ||
for i = 1:length(optionnames) | ||
namei = validatestring(optionnames{i}, validnames); | ||
valuei = optionvalues{i}; | ||
|
@@ -70,13 +51,13 @@ | |
error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:UseJsonNameNotScalarLogical", "UseJsonName must be a scalar logical.") | ||
end | ||
usejsonname = logical(valuei); | ||
elseif strcmp(namei, "Timeout") | ||
elseif strcmp(namei, "Timeout") | ||
if ~(isduration(valuei) && isscalar(valuei)) | ||
error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:TimeoutNotScalarDuration", "Timeout must be a scalar duration."); | ||
end | ||
timeout = valuei; | ||
timeout_millis = milliseconds(timeout); | ||
else % HttpHeaders | ||
elseif strcmp(namei, "HttpHeaders") | ||
if ~isa(valuei, "dictionary") | ||
error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:HttpHeadersNotDictionary", "HttpHeaders input must be a dictionary."); | ||
end | ||
|
@@ -86,18 +67,21 @@ | |
if ~isstring(headervalues) | ||
error("opentelemetry:exporters:otlp:OtlpHttpMetricExporter:HttpHeadersNonStringValues", "HttpHeaders dictionary values must be strings.") | ||
end | ||
elseif strcmp(namei, "PreferredAggregationTemporality") | ||
temporality = validatestring(valuei, ["Cumulative", "Delta"]); | ||
end | ||
|
||
end | ||
|
||
obj = [email protected](... | ||
"libmexclass.opentelemetry.exporters.OtlpHttpMetricExporterProxy", ... | ||
endpoint, dataformat, jsonbytesmapping, usejsonname, ... | ||
timeout_millis, headerkeys, headervalues); | ||
timeout_millis, headerkeys, headervalues, temporality); | ||
|
||
% populate immutable properties | ||
if endpoint == "" || dataformat == "" || jsonbytesmapping == "" || ... | ||
timeout_millis < 0 | ||
[defaultendpoint, defaultformat, defaultmapping, defaultmillis] = ... | ||
[defaultendpoint, defaultformat, defaultmapping, defaultmillis, defaulttemporality] = ... | ||
getDefaultOptionValues(obj); | ||
end | ||
if endpoint == "" % not specified, use default value | ||
|
@@ -126,6 +110,11 @@ | |
else | ||
obj.HttpHeaders = httpheaders; | ||
end | ||
if temporality == "" | ||
obj.PreferredAggregationTemporality = defaulttemporality; | ||
else | ||
obj.PreferredAggregationTemporality = temporality; | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.