Skip to content

Commit

Permalink
Clean up code and finish shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
dnarula-mw committed Oct 30, 2023
1 parent ff030ae commit e1c58c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions sdk/metrics/+opentelemetry/+sdk/+metrics/MeterProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
% assert(mpproxy.Name == "libmexclass.opentelemetry.MeterProviderProxy");
obj.Proxy = libmexclass.proxy.Proxy("Name", ...
"libmexclass.opentelemetry.sdk.MeterProviderProxy", ...
"ConstructorArguments", {mpproxy.ID});
"ConstructorArguments", {mpproxy.ID, true});
% leave other properties unassigned, they won't be used
else
obj.Proxy = libmexclass.proxy.Proxy("Name", ...
"libmexclass.opentelemetry.sdk.MeterProviderProxy", ...
"ConstructorArguments", {reader.Proxy.ID, 0});
"ConstructorArguments", {reader.Proxy.ID, false});
obj.MetricReader = reader;
end
end
Expand Down
3 changes: 2 additions & 1 deletion sdk/metrics/src/MeterProviderProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace libmexclass::opentelemetry::sdk {
libmexclass::proxy::MakeResult MeterProviderProxy::make(const libmexclass::proxy::FunctionArguments& constructor_arguments) {

libmexclass::proxy::MakeResult out;
if (constructor_arguments.getNumberOfElements() == 1) {
matlab::data::TypedArray<bool> is_api = constructor_arguments[1];
if (is_api[0]) {
// if argument is 1, assume it is an API Meter Provider to support type conversion
matlab::data::TypedArray<uint64_t> mpid_mda = constructor_arguments[0];
libmexclass::proxy::ID mpid = mpid_mda[0];
Expand Down
24 changes: 12 additions & 12 deletions test/tmetrics.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function testAddMetricReader(testCase)
% adding a single value
ct.add(1);
pause(2.5);
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
result_count = numel(results);
verifyEqual(testCase,result_count, 2);
Expand Down Expand Up @@ -136,7 +136,7 @@ function testCounterBasic(testCase)
pause(2.5);

% fetch result
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};

Expand Down Expand Up @@ -180,7 +180,7 @@ function testCounterDelta(testCase)

% fetch results
pause(2.5);
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
dp1 = results{1}.resourceMetrics.scopeMetrics.metrics.sum.dataPoints;
dp2 = results{2}.resourceMetrics.scopeMetrics.metrics.sum.dataPoints;
Expand Down Expand Up @@ -219,7 +219,7 @@ function testCounterAddAttributes(testCase)
pause(2.5);

% fetch result
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};

Expand Down Expand Up @@ -263,7 +263,7 @@ function testCounterAddNegative(testCase)
pause(2.5);

% fetch results
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};
dp = results.resourceMetrics.scopeMetrics.metrics.sum.dataPoints;
Expand Down Expand Up @@ -303,7 +303,7 @@ function testUpDownCounterBasic(testCase)
pause(5);

% fetch result
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};

Expand Down Expand Up @@ -348,7 +348,7 @@ function testUpDownCounterAddAttributes(testCase)
pause(5);

% fetch result
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};
dp = results.resourceMetrics.scopeMetrics.metrics.sum.dataPoints;
Expand Down Expand Up @@ -397,7 +397,7 @@ function testHistogramBasic(testCase)
pause(10);

% fetch results
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};
dp = results.resourceMetrics.scopeMetrics.metrics.histogram.dataPoints;
Expand Down Expand Up @@ -454,7 +454,7 @@ function testHistogramRecordAttributes(testCase)
pause(10);

% fetch results
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
results = results{end};
dp = results.resourceMetrics.scopeMetrics.metrics.histogram.dataPoints;
Expand Down Expand Up @@ -511,7 +511,7 @@ function testHistogramDelta(testCase)
pause(2.5);

% fetch results
clear p;
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(p));
results = readJsonResults(testCase);
rsize = size(results);
for i = 1:rsize(2)
Expand Down Expand Up @@ -559,10 +559,10 @@ function testGetSetMeterProvider(testCase)

pause(2.5);

% perform test comparisons
%Shutdown the Meter Provider
verifyTrue(testCase, opentelemetry.sdk.metrics.Cleanup.shutdown(mp));
clear mp;

% perform test comparisons
results = readJsonResults(testCase);
results = results{1};
% check a counter has been created, and check its resource to identify the
Expand Down

0 comments on commit e1c58c4

Please sign in to comment.