-
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.
Merge pull request #61 from mathworks/metrics_merge
refactor exporter code to enable more code sharing and remove duplications
- Loading branch information
Showing
11 changed files
with
149 additions
and
123 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
32 changes: 32 additions & 0 deletions
32
exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m
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 |
---|---|---|
@@ -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 |
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
23 changes: 23 additions & 0 deletions
23
exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpHttpValidator.m
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 |
---|---|---|
@@ -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 |
Oops, something went wrong.