diff --git a/sdk/metrics/+opentelemetry/+sdk/+metrics/MeterProvider.m b/sdk/metrics/+opentelemetry/+sdk/+metrics/MeterProvider.m index 60d3ab3..646a078 100644 --- a/sdk/metrics/+opentelemetry/+sdk/+metrics/MeterProvider.m +++ b/sdk/metrics/+opentelemetry/+sdk/+metrics/MeterProvider.m @@ -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 diff --git a/sdk/metrics/src/MeterProviderProxy.cpp b/sdk/metrics/src/MeterProviderProxy.cpp index 16eae65..e3f5f28 100644 --- a/sdk/metrics/src/MeterProviderProxy.cpp +++ b/sdk/metrics/src/MeterProviderProxy.cpp @@ -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 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 mpid_mda = constructor_arguments[0]; libmexclass::proxy::ID mpid = mpid_mda[0]; diff --git a/test/tmetrics.m b/test/tmetrics.m index a64b128..99587d4 100644 --- a/test/tmetrics.m +++ b/test/tmetrics.m @@ -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); @@ -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}; @@ -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; @@ -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}; @@ -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; @@ -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}; @@ -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; @@ -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; @@ -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; @@ -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) @@ -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