Skip to content

Commit 085ea90

Browse files
authored
Merge pull request #89 from mathworks/release_1_6_0
Release 1 6 0
2 parents f2b7f79 + 714376e commit 085ea90

File tree

6 files changed

+86
-39
lines changed

6 files changed

+86
-39
lines changed

CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,15 @@ else()
125125
include(ExternalProject)
126126
set(OTEL_CPP_PROJECT_NAME opentelemetry-cpp)
127127
set(OTEL_CPP_GIT_REPOSITORY "https://github.com/open-telemetry/opentelemetry-cpp.git")
128-
set(OTEL_CPP_GIT_TAG "11d5d9e")
128+
set(OTEL_CPP_GIT_TAG "e1119ed")
129129

130130
if(DEFINED OTEL_CPP_PREFIX)
131131
string(REPLACE "\\" "/" OTEL_CPP_PREFIX ${OTEL_CPP_PREFIX})
132132
else()
133133
set(OTEL_CPP_PREFIX ${CMAKE_BINARY_DIR}/otel-cpp)
134134
endif()
135135

136-
if(WITH_OTLP_GRPC)
137-
set(OTEL_CPP_CXX_STANDARD 14) # Abseil requires at least Cxx14
138-
else()
139-
set(OTEL_CPP_CXX_STANDARD 11)
140-
endif()
136+
set(OTEL_CPP_CXX_STANDARD 14)
141137

142138
if(NOT APPLE OR SKIP_OTEL_CPP_PATCH)
143139
set(patch_command "")

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
MATLAB® interface to [OpenTelemetry™](https://opentelemetry.io/), based on the [OpenTelemetry Specification](https://opentelemetry.io/docs/reference/specification/). OpenTelemetry is an observability framework for creating and managing telemetry data, such as traces, metrics, and logs. This data can then be sent to an observability back-end for monitoring, alerts, and analysis.
55

66
### Status
7-
- Currently only tracing and metrics are supported. Logs will be in the future.
8-
- View class in metrics is only partially supported. The properties **Aggregation** and **AllowedAttributes** are not yet supported.
9-
- This package is supported and has been tested on Windows®, Linux®, and macOS.
7+
- Tracing and metrics are fully supported. Logs will be in the future.
8+
- Supported and tested on Windows®, Linux®, and macOS.
9+
- Attributes in asynchronous metric instruments are currently ignored because of an issue in the opentelemetry-cpp layer.
1010

1111
### MathWorks Products (https://www.mathworks.com)
1212

@@ -91,4 +91,4 @@ The license is available in the License file within this repository
9191
## Community Support
9292
[MATLAB Central](https://www.mathworks.com/matlabcentral)
9393

94-
Copyright 2023 The MathWorks, Inc.
94+
Copyright 2023-2024 The MathWorks, Inc.

examples/context_propagation/cpp/client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void sendRequest(const std::string &url)
8484
prop->Inject(carrier, current_ctx);
8585

8686
// send http request
87-
http_client::Result result = http_client->Post(url, body, carrier.headers_);
87+
http_client::Result result = http_client->PostNoSsl(url, body, carrier.headers_);
8888
if (result)
8989
{
9090
// set span attributes

sdk/metrics/+opentelemetry/+sdk/+metrics/View.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
% * Ignore unwanted instruments
88
% * Ignore unwanted attributes
99

10-
% Copyright 2023 The MathWorks, Inc.
10+
% Copyright 2023-2024 The MathWorks, Inc.
1111

1212
properties (GetAccess={?opentelemetry.sdk.metrics.MeterProvider})
1313
Proxy % Proxy object to interface C++ code
@@ -91,15 +91,13 @@
9191
options.MeterName {mustBeTextScalar} = ""
9292
options.MeterVersion {mustBeTextScalar} = ""
9393
options.MeterSchema {mustBeTextScalar} = ""
94-
%options.AllowedAttributes {mustBeText, mustBeVector} % no default here
95-
%options.Aggregation {mustBeTextScalar} = "default"
94+
options.AllowedAttributes {mustBeText, mustBeVector} % no default here
95+
options.Aggregation {mustBeTextScalar} = "default"
9696
options.HistogramBinEdges {mustBeNumeric, mustBeVector} = zeros(1,0)
9797
end
98-
99-
% Aggregation and AllowedAttributes are not yet supported
100-
options.Aggregation = "default";
10198

102-
instrument_types = ["counter", "histogram", "updowncounter"];
99+
instrument_types = ["counter", "histogram", "updowncounter", ...
100+
"observablecounter", "observableupdowncounter", "observablegauge"];
103101
instrument_type = validatestring(options.InstrumentType, instrument_types);
104102

105103
aggregation_types = ["drop", "histogram", "lastvalue", "sum", "default"];

test/tmetrics.m

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ function testCounterInvalidAdd(testCase)
197197
% fetch results
198198
clear p;
199199
results = readJsonResults(testCase);
200-
results = results{end};
201-
202-
% verify that the counter value is still 0
203-
verifyEqual(testCase, ...
204-
results.resourceMetrics.scopeMetrics.metrics.sum.dataPoints.asDouble, 0);
200+
verifyEmpty(testCase, results); % results should be empty since all adds were invalid
205201
end
206202

207203

@@ -516,10 +512,6 @@ function testGetSetMeterProvider(testCase)
516512
methods (Test, ParameterCombination="sequential")
517513
function testAsynchronousInstrumentBasic(testCase, create_async, datapoint_name)
518514
% test basic functionalities of an observable counter
519-
520-
testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
521-
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");
522-
523515
countername = "bar";
524516
callback = @callbackNoAttributes;
525517

@@ -549,10 +541,9 @@ function testAsynchronousInstrumentBasic(testCase, create_async, datapoint_name)
549541

550542
function testAsynchronousInstrumentAttributes(testCase, create_async, datapoint_name)
551543
% test for attributes when observing metrics for an observable counter
552-
553-
testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
554-
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");
555-
544+
545+
testCase.assumeTrue(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");
546+
556547
countername = "bar";
557548
callback = @callbackWithAttributes;
558549

@@ -586,10 +577,6 @@ function testAsynchronousInstrumentAttributes(testCase, create_async, datapoint_
586577

587578
function testAsynchronousInstrumentAnonymousCallback(testCase, create_async, datapoint_name)
588579
% use an anonymous function as callback
589-
590-
testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
591-
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");
592-
593580
countername = "bar";
594581
addvalue = 20;
595582
callback = @(x)callbackOneInput(addvalue);
@@ -617,9 +604,8 @@ function testAsynchronousInstrumentAnonymousCallback(testCase, create_async, dat
617604
function testAsynchronousInstrumentMultipleCallbacks(testCase, create_async, datapoint_name)
618605
% Observable counter with more than one callbacks
619606

620-
testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
621-
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");
622-
607+
testCase.assumeTrue(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");
608+
623609
countername = "bar";
624610

625611
p = opentelemetry.sdk.metrics.MeterProvider(testCase.ShortIntervalReader);

test/tmetrics_sdk.m

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ function testViewBasic(testCase)
186186
% verify counter value
187187
verifyEqual(testCase, dp.asDouble, val);
188188
end
189-
190189

191190
function testViewHistogram(testCase)
192191
% testViewHistogram: Change histogram bins
@@ -240,6 +239,74 @@ function testViewHistogram(testCase)
240239
verifyEqual(testCase, dp.bucketCounts, expected_buckets);
241240
end
242241

242+
function testViewAggregation(testCase)
243+
% testViewAggregation: change aggregation of metric instruments
244+
metername = "foo";
245+
countername = "bar";
246+
view = opentelemetry.sdk.metrics.View(InstrumentType="Counter", ...
247+
InstrumentName=countername, Aggregation="LastValue");
248+
mp = opentelemetry.sdk.metrics.MeterProvider(...
249+
testCase.ShortIntervalReader, View=view);
250+
251+
m = getMeter(mp, metername);
252+
c = createCounter(m, countername);
253+
254+
% add values
255+
maxi = 5;
256+
for i = 1:maxi
257+
c.add(i);
258+
end
259+
260+
pause(testCase.WaitTime);
261+
262+
clear mp;
263+
results = readJsonResults(testCase);
264+
results = results{end};
265+
266+
% verify counter name
267+
verifyEqual(testCase, string(results.resourceMetrics.scopeMetrics.metrics.name), countername);
268+
269+
% verify counter value is the last value rather than the sum
270+
dp = results.resourceMetrics.scopeMetrics.metrics.gauge.dataPoints;
271+
verifyEqual(testCase, dp.asDouble, maxi);
272+
end
273+
274+
function testViewAttributes(testCase)
275+
% testViewAttributes: filter out attributes
276+
metername = "foo";
277+
countername = "bar";
278+
view = opentelemetry.sdk.metrics.View(InstrumentType="Counter", ...
279+
InstrumentName=countername, AllowedAttributes="Building");
280+
mp = opentelemetry.sdk.metrics.MeterProvider(...
281+
testCase.ShortIntervalReader, View=view);
282+
283+
m = getMeter(mp, metername);
284+
c = createCounter(m, countername);
285+
286+
% add values
287+
values = 10:10:40;
288+
add(c, values(1), "Building", 1, "Room", 1);
289+
add(c, values(2), "Building", 1, "Room", 2);
290+
add(c, values(3), "Building", 1, "Room", 1);
291+
add(c, values(4), "Building", 1, "Room", 2);
292+
293+
pause(testCase.WaitTime);
294+
295+
clear mp;
296+
results = readJsonResults(testCase);
297+
results = results{end};
298+
299+
% verify counter name
300+
verifyEqual(testCase, string(results.resourceMetrics.scopeMetrics.metrics.name), countername);
301+
302+
% verify "Room" attribute has been filtered out
303+
dp = results.resourceMetrics.scopeMetrics.metrics.sum.dataPoints;
304+
verifyEqual(testCase, dp.asDouble, sum(values));
305+
verifyLength(testCase, dp.attributes, 1);
306+
verifyEqual(testCase, string(dp.attributes(1).key), "Building");
307+
verifyEqual(testCase, dp.attributes(1).value.doubleValue, 1);
308+
end
309+
243310
function testMultipleViews(testCase)
244311
% testMultipleView: Applying multiple views to a meter provider
245312

0 commit comments

Comments
 (0)