Skip to content

Commit

Permalink
Release 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanpo committed Feb 22, 2024
1 parent f2b7f79 commit 434ba0b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 38 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,15 @@ else()
include(ExternalProject)
set(OTEL_CPP_PROJECT_NAME opentelemetry-cpp)
set(OTEL_CPP_GIT_REPOSITORY "https://github.com/open-telemetry/opentelemetry-cpp.git")
set(OTEL_CPP_GIT_TAG "11d5d9e")
set(OTEL_CPP_GIT_TAG "e1119ed")

if(DEFINED OTEL_CPP_PREFIX)
string(REPLACE "\\" "/" OTEL_CPP_PREFIX ${OTEL_CPP_PREFIX})
else()
set(OTEL_CPP_PREFIX ${CMAKE_BINARY_DIR}/otel-cpp)
endif()

if(WITH_OTLP_GRPC)
set(OTEL_CPP_CXX_STANDARD 14) # Abseil requires at least Cxx14
else()
set(OTEL_CPP_CXX_STANDARD 11)
endif()
set(OTEL_CPP_CXX_STANDARD 14)

if(NOT APPLE OR SKIP_OTEL_CPP_PATCH)
set(patch_command "")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
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.

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

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

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

Copyright 2023 The MathWorks, Inc.
Copyright 2023-2024 The MathWorks, Inc.
12 changes: 5 additions & 7 deletions sdk/metrics/+opentelemetry/+sdk/+metrics/View.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% * Ignore unwanted instruments
% * Ignore unwanted attributes

% Copyright 2023 The MathWorks, Inc.
% Copyright 2023-2024 The MathWorks, Inc.

properties (GetAccess={?opentelemetry.sdk.metrics.MeterProvider})
Proxy % Proxy object to interface C++ code
Expand Down Expand Up @@ -91,15 +91,13 @@
options.MeterName {mustBeTextScalar} = ""
options.MeterVersion {mustBeTextScalar} = ""
options.MeterSchema {mustBeTextScalar} = ""
%options.AllowedAttributes {mustBeText, mustBeVector} % no default here
%options.Aggregation {mustBeTextScalar} = "default"
options.AllowedAttributes {mustBeText, mustBeVector} % no default here
options.Aggregation {mustBeTextScalar} = "default"
options.HistogramBinEdges {mustBeNumeric, mustBeVector} = zeros(1,0)
end

% Aggregation and AllowedAttributes are not yet supported
options.Aggregation = "default";

instrument_types = ["counter", "histogram", "updowncounter"];
instrument_types = ["counter", "histogram", "updowncounter", ...
"observablecounter", "observableupdowncounter", "observablegauge"];
instrument_type = validatestring(options.InstrumentType, instrument_types);

aggregation_types = ["drop", "histogram", "lastvalue", "sum", "default"];
Expand Down
26 changes: 6 additions & 20 deletions test/tmetrics.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ function testCounterInvalidAdd(testCase)
% fetch results
clear p;
results = readJsonResults(testCase);
results = results{end};

% verify that the counter value is still 0
verifyEqual(testCase, ...
results.resourceMetrics.scopeMetrics.metrics.sum.dataPoints.asDouble, 0);
verifyEmpty(testCase, results); % results should be empty since all adds were invalid
end


Expand Down Expand Up @@ -516,10 +512,6 @@ function testGetSetMeterProvider(testCase)
methods (Test, ParameterCombination="sequential")
function testAsynchronousInstrumentBasic(testCase, create_async, datapoint_name)
% test basic functionalities of an observable counter

testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");

countername = "bar";
callback = @callbackNoAttributes;

Expand Down Expand Up @@ -549,10 +541,9 @@ function testAsynchronousInstrumentBasic(testCase, create_async, datapoint_name)

function testAsynchronousInstrumentAttributes(testCase, create_async, datapoint_name)
% test for attributes when observing metrics for an observable counter

testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");


testCase.assumeTrue(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");

countername = "bar";
callback = @callbackWithAttributes;

Expand Down Expand Up @@ -586,10 +577,6 @@ function testAsynchronousInstrumentAttributes(testCase, create_async, datapoint_

function testAsynchronousInstrumentAnonymousCallback(testCase, create_async, datapoint_name)
% use an anonymous function as callback

testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");

countername = "bar";
addvalue = 20;
callback = @(x)callbackOneInput(addvalue);
Expand Down Expand Up @@ -617,9 +604,8 @@ function testAsynchronousInstrumentAnonymousCallback(testCase, create_async, dat
function testAsynchronousInstrumentMultipleCallbacks(testCase, create_async, datapoint_name)
% Observable counter with more than one callbacks

testCase.assumeTrue(isequal(create_async, @createObservableGauge), ...
"Sporadic failures for counters and updowncounters fixed in otel-cpp 1.14.0");

testCase.assumeTrue(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");

countername = "bar";

p = opentelemetry.sdk.metrics.MeterProvider(testCase.ShortIntervalReader);
Expand Down
69 changes: 68 additions & 1 deletion test/tmetrics_sdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ function testViewBasic(testCase)
% verify counter value
verifyEqual(testCase, dp.asDouble, val);
end


function testViewHistogram(testCase)
% testViewHistogram: Change histogram bins
Expand Down Expand Up @@ -240,6 +239,74 @@ function testViewHistogram(testCase)
verifyEqual(testCase, dp.bucketCounts, expected_buckets);
end

function testViewAggregation(testCase)
% testViewAggregation: change aggregation of metric instruments
metername = "foo";
countername = "bar";
view = opentelemetry.sdk.metrics.View(InstrumentType="Counter", ...
InstrumentName=countername, Aggregation="LastValue");
mp = opentelemetry.sdk.metrics.MeterProvider(...
testCase.ShortIntervalReader, View=view);

m = getMeter(mp, metername);
c = createCounter(m, countername);

% add values
maxi = 5;
for i = 1:maxi
c.add(i);
end

pause(testCase.WaitTime);

clear mp;
results = readJsonResults(testCase);
results = results{end};

% verify counter name
verifyEqual(testCase, string(results.resourceMetrics.scopeMetrics.metrics.name), countername);

% verify counter value is the last value rather than the sum
dp = results.resourceMetrics.scopeMetrics.metrics.gauge.dataPoints;
verifyEqual(testCase, dp.asDouble, maxi);
end

function testViewAttributes(testCase)
% testViewAttributes: filter out attributes
metername = "foo";
countername = "bar";
view = opentelemetry.sdk.metrics.View(InstrumentType="Counter", ...
InstrumentName=countername, AllowedAttributes="Building");
mp = opentelemetry.sdk.metrics.MeterProvider(...
testCase.ShortIntervalReader, View=view);

m = getMeter(mp, metername);
c = createCounter(m, countername);

% add values
values = 10:10:40;
add(c, values(1), "Building", 1, "Room", 1);
add(c, values(2), "Building", 1, "Room", 2);
add(c, values(3), "Building", 1, "Room", 1);
add(c, values(4), "Building", 1, "Room", 2);

pause(testCase.WaitTime);

clear mp;
results = readJsonResults(testCase);
results = results{end};

% verify counter name
verifyEqual(testCase, string(results.resourceMetrics.scopeMetrics.metrics.name), countername);

% verify "Room" attribute has been filtered out
dp = results.resourceMetrics.scopeMetrics.metrics.sum.dataPoints;
verifyEqual(testCase, dp.asDouble, sum(values));
verifyLength(testCase, dp.attributes, 1);
verifyEqual(testCase, string(dp.attributes(1).key), "Building");
verifyEqual(testCase, dp.attributes(1).value.doubleValue, 1);
end

function testMultipleViews(testCase)
% testMultipleView: Applying multiple views to a meter provider

Expand Down

0 comments on commit 434ba0b

Please sign in to comment.