Skip to content

Commit 7abe328

Browse files
authored
Merge pull request #93 from mathworks/package
Release 1.6.1
2 parents 085ea90 + 6409673 commit 7abe328

File tree

9 files changed

+205
-26
lines changed

9 files changed

+205
-26
lines changed

.github/workflows/build.yml renamed to .github/workflows/build_and_test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
name: "OpenTelemetry-Matlab"
1+
name: "Build and Run Tests"
22
on:
33
workflow_dispatch:
44
push:
55
jobs:
66
build-and-run-tests-ubuntu:
7-
runs-on: ubuntu-latest
7+
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
8+
# Instead, run on ubuntu-20.04
9+
runs-on: ubuntu-20.04
810
env:
911
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
1012
SYSTEM_LIBSTDCPP_PATH: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
@@ -24,11 +26,6 @@ jobs:
2426
cmake --build build --config Release --target install
2527
- name: Run tests
2628
env:
27-
# The version of libstdc++ that is bundled with MATLAB is used when building MEX files.
28-
# This version of libstdc++ is incompatible with the system version of libstdc++.
29-
# As a workaround, set LD_PRELOAD to use the system version of libstdc++ with MATLAB.
30-
LD_PRELOAD: ${{ env.SYSTEM_LIBSTDCPP_PATH }}
31-
3229
# Add the installation directory to the MATLAB Search Path by
3330
# setting the MATLABPATH environment variable.
3431
MATLABPATH: ${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: "Publish mltbx"
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: published
6+
jobs:
7+
build-ubuntu:
8+
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
9+
# Instead, run on ubuntu-20.04
10+
runs-on: ubuntu-20.04
11+
env:
12+
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
13+
steps:
14+
- name: Download OpenTelemetry-Matlab source
15+
uses: actions/checkout@v3
16+
with:
17+
path: opentelemetry-matlab
18+
- name: Install MATLAB
19+
uses: matlab-actions/setup-matlab@v2
20+
with:
21+
products: MATLAB_Compiler
22+
- name: Build OpenTelemetry-Matlab
23+
run: |
24+
cd opentelemetry-matlab
25+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
26+
cmake --build build --config Release --target install
27+
- name: Compress into single artifact
28+
working-directory: ${{ github.workspace }}
29+
run: tar -czf otel-matlab-ubuntu.tar.gz otel_matlab_install
30+
- name: Upload artifacts
31+
uses: actions/upload-artifact@v2
32+
with:
33+
name: otel-matlab-ubuntu.tar.gz
34+
path: ${{ github.workspace }}/otel-matlab-ubuntu.tar.gz
35+
build-windows:
36+
runs-on: windows-latest
37+
env:
38+
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
39+
steps:
40+
- name: Download OpenTelemetry-Matlab source
41+
uses: actions/checkout@v3
42+
with:
43+
path: opentelemetry-matlab
44+
- name: Install MATLAB
45+
uses: matlab-actions/setup-matlab@v2
46+
with:
47+
products: MATLAB_Compiler
48+
- name: Build OpenTelemetry-Matlab
49+
run: |
50+
cd opentelemetry-matlab
51+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
52+
cmake --build build --config Release --target install
53+
- name: Compress into single artifact
54+
working-directory: ${{ github.workspace }}
55+
run: tar -czf otel-matlab-windows.tar.gz otel_matlab_install
56+
- name: Upload artifacts
57+
uses: actions/upload-artifact@v2
58+
with:
59+
name: otel-matlab-windows.tar.gz
60+
path: ${{ github.workspace }}/otel-matlab-windows.tar.gz
61+
build-macos:
62+
runs-on: macos-latest
63+
env:
64+
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
65+
steps:
66+
- name: Download OpenTelemetry-Matlab source
67+
uses: actions/checkout@v3
68+
with:
69+
path: opentelemetry-matlab
70+
- name: Install MATLAB
71+
uses: matlab-actions/setup-matlab@v2
72+
with:
73+
products: MATLAB_Compiler
74+
- name: Build OpenTelemetry-Matlab
75+
run: |
76+
cd opentelemetry-matlab
77+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
78+
cmake --build build --config Release --target install
79+
- name: Compress into single artifact
80+
working-directory: ${{ github.workspace }}
81+
run: tar -czf otel-matlab-macos.tar.gz otel_matlab_install
82+
- name: Upload artifacts
83+
uses: actions/upload-artifact@v2
84+
with:
85+
name: otel-matlab-macos.tar.gz
86+
path: ${{ github.workspace }}/otel-matlab-macos.tar.gz
87+
package-mltbx:
88+
name: Package MATLAB Toolbox (MLTBX) Files
89+
runs-on: ubuntu-20.04
90+
needs:
91+
- build-ubuntu
92+
- build-windows
93+
- build-macos
94+
env:
95+
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
96+
steps:
97+
- name: Checkout OpenTelemetry-Matlab
98+
uses: actions/checkout@v3
99+
with:
100+
path: OpenTelemetry-Matlab
101+
- name: Read version
102+
id: getversion
103+
working-directory: OpenTelemetry-Matlab
104+
run: echo "version=$(cat VERSION.txt)" >> $GITHUB_OUTPUT
105+
- name: Download Artifacts
106+
uses: actions/download-artifact@v3
107+
with:
108+
path: artifacts-downloaded
109+
- name: Decompress Artifacts
110+
run: |
111+
mv artifacts-downloaded/*/*.tar.gz .
112+
tar -xzvf otel-matlab-ubuntu.tar.gz
113+
tar -xzvf otel-matlab-macos.tar.gz
114+
tar -xzvf otel-matlab-windows.tar.gz
115+
- name: Install MATLAB
116+
uses: matlab-actions/setup-matlab@v1
117+
- name: Run commands
118+
env:
119+
MATLABPATH: OpenTelemetry-Matlab/tools
120+
OTEL_MATLAB_TOOLBOX_FOLDER: otel_matlab_install
121+
OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER:
122+
OTEL_MATLAB_TOOLBOX_VERSION: ${{ steps.getversion.outputs.version }}
123+
uses: matlab-actions/run-command@v1
124+
with:
125+
command: packageMatlabInterface
126+
- name: Compress Asset
127+
run: zip otel-matlab-${{ github.event.release.tag_name }}.mltbx.zip otel-matlab.mltbx
128+
- name: Upload Release Asset
129+
uses: actions/upload-release-asset@v1
130+
with:
131+
upload_url: https://uploads.github.com/repos/mathworks/OpenTelemetry-Matlab/releases/${{ github.event.release.id }}/assets{?name,label}`
132+
asset_path: ./otel-matlab-${{ github.event.release.tag_name }}.mltbx.zip
133+
asset_name: otel-matlab-${{ github.event.release.tag_name }}.mltbx.zip
134+
asset_content_type: application/zip

CMakeLists.txt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ endif()
8888

8989
set(CLIENT_PROJECT_NAME otel-matlab)
9090

91-
project(${CLIENT_PROJECT_NAME} VERSION 0.1.0)
91+
# read version number
92+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt OTEL_MATLAB_VERSION_RAW)
93+
string(STRIP ${OTEL_MATLAB_VERSION_RAW} OTEL_MATLAB_VERSION)
94+
95+
96+
project(${CLIENT_PROJECT_NAME} VERSION ${OTEL_MATLAB_VERSION})
9297

9398
# ######################################
9499
# libmexclass
@@ -125,7 +130,7 @@ else()
125130
include(ExternalProject)
126131
set(OTEL_CPP_PROJECT_NAME opentelemetry-cpp)
127132
set(OTEL_CPP_GIT_REPOSITORY "https://github.com/open-telemetry/opentelemetry-cpp.git")
128-
set(OTEL_CPP_GIT_TAG "e1119ed")
133+
set(OTEL_CPP_GIT_TAG "a799f4a")
129134

130135
if(DEFINED OTEL_CPP_PREFIX)
131136
string(REPLACE "\\" "/" OTEL_CPP_PREFIX ${OTEL_CPP_PREFIX})
@@ -270,17 +275,16 @@ if(WITH_OTLP_GRPC)
270275
set(OTLP_MACROS ${OTLP_MACROS} "-D WITH_OTLP_GRPC ")
271276
endif()
272277
endif()
273-
274-
# On Windows, suppress a compiler warning about deprecation of result_of
275-
if(WIN32)
276-
set(CUSTOM_CXX_FLAGS -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING)
277-
else()
278-
set(CUSTOM_CXX_FLAGS "")
279-
endif()
280278

281279
if(WIN32)
280+
# On Windows, suppress a compiler warning about deprecation of result_of
281+
set(CUSTOM_CXX_FLAGS -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING)
282+
# pass in version number
283+
set(OTLP_MACROS ${OTLP_MACROS} /DOTEL_MATLAB_VERSION="${OTEL_MATLAB_VERSION}")
282284
set(OTEL_PROTO_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
283285
else()
286+
set(CUSTOM_CXX_FLAGS "")
287+
set(OTLP_MACROS ${OTLP_MACROS} "-D OTEL_MATLAB_VERSION=\"${OTEL_MATLAB_VERSION}\"")
284288
set(OTEL_PROTO_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
285289
endif()
286290

@@ -412,6 +416,7 @@ set(OTLP_GRPC_EXPORTER_MATLAB_SOURCES
412416
${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m
413417
${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m
414418
${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m)
419+
set(OTLP_MISC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)
415420

416421
set(OTLP_EXPORTERS_DIR +opentelemetry/+exporters/+otlp)
417422

@@ -430,6 +435,10 @@ endif()
430435
if(WITH_OTLP_GRPC)
431436
install(FILES ${OTLP_GRPC_EXPORTER_MATLAB_SOURCES} DESTINATION ${OTLP_EXPORTERS_DIR})
432437
endif()
438+
# Install license and version. The only reason these are needed is to work around a packaging bug where if
439+
# all files are in packages (+xxx directories), matlab.addons.toolbox.packageToolbox refuses to add the
440+
# toolbox path into MATLAB path. This issue is fixed in R2024a
441+
install(FILES ${OTLP_MISC_FILES} DESTINATION .)
433442

434443
# Install dependent runtime libraries
435444
set(LIBMEXCLASS_PROXY_INSTALLED_DIR +libmexclass/+proxy)

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ MATLAB® interface to [OpenTelemetry™](https://opentelemetry.io/), base
66
### Status
77
- Tracing and metrics are fully supported. Logs will be in the future.
88
- 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.
109

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

@@ -21,6 +20,13 @@ Requires MATLAB release R2022b or newer
2120
## Installation
2221
Installation instructions
2322

23+
### Installing With Toolbox Package
24+
1. Under "Assets" of a release, download the toolbox package .mltbx file.
25+
2. Start MATLAB.
26+
3. In the Current Folder browser, navigate to the .mltbx file.
27+
4. Right click on the .mltbx file and select "Install".
28+
29+
### Building From Source
2430
Before proceeding, ensure that the below products are installed:
2531
* [MATLAB](https://www.mathworks.com/products/matlab.html)
2632

VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.6.1

sdk/common/src/resource.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The MathWorks, Inc.
1+
// Copyright 2023-2024 The MathWorks, Inc.
22

33
#include <list>
44

@@ -8,8 +8,6 @@
88
#include "opentelemetry/common/attribute_value.h"
99
#include "opentelemetry/nostd/string_view.h"
1010

11-
#define OTEL_MATLAB_VERSION "1.2.0"
12-
1311
namespace common = opentelemetry::common;
1412
namespace nostd = opentelemetry::nostd;
1513

test/tmetrics.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,6 @@ function testAsynchronousInstrumentBasic(testCase, create_async, datapoint_name)
541541

542542
function testAsynchronousInstrumentAttributes(testCase, create_async, datapoint_name)
543543
% test for attributes when observing metrics for an observable counter
544-
545-
testCase.assumeTrue(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");
546-
547544
countername = "bar";
548545
callback = @callbackWithAttributes;
549546

@@ -604,8 +601,6 @@ function testAsynchronousInstrumentAnonymousCallback(testCase, create_async, dat
604601
function testAsynchronousInstrumentMultipleCallbacks(testCase, create_async, datapoint_name)
605602
% Observable counter with more than one callbacks
606603

607-
testCase.assumeTrue(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");
608-
609604
countername = "bar";
610605

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

test/ttrace.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ function testBasic(testCase)
8888

8989
versionidx = find(resourcekeys == "telemetry.sdk.version");
9090
verifyNotEmpty(testCase, versionidx);
91-
verifyEqual(testCase, results.resourceSpans.resource.attributes(versionidx).value.stringValue, '1.2.0');
91+
versionstr = strip(fileread(fullfile("..", "VERSION.txt")));
92+
verifyEqual(testCase, results.resourceSpans.resource.attributes(versionidx).value.stringValue, versionstr);
9293

9394
nameidx = find(resourcekeys == "telemetry.sdk.name");
9495
verifyNotEmpty(testCase, nameidx);

tools/packageMatlabInterface.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
% packageMatlabInterface.m
2+
% This script packages installed files for OpenTelemetry interface and
3+
% package them into a single .mltbx file. The location of the installed
4+
% files is taken from environment variable OTEL_MATLAB_TOOLBOX_FOLDER and
5+
% the resulting .mltbx file location is taken from environment variable
6+
% OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER.
7+
8+
% Copyright 2024 The MathWorks, Inc.
9+
10+
toolboxFolder = string(getenv("OTEL_MATLAB_TOOLBOX_FOLDER"));
11+
outputFolder = string(getenv("OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER"));
12+
toolboxVersion = string(getenv("OTEL_MATLAB_TOOLBOX_VERSION"));
13+
14+
% Output folder must exist.
15+
mkdir(outputFolder);
16+
17+
disp("Toolbox Folder: " + toolboxFolder);
18+
disp("Output Folder: " + outputFolder);
19+
disp("Toolbox Version:" + toolboxVersion);
20+
21+
identifier = "dc2cae2f-4f43-4d2c-b6ed-f1a59f0dfcdf";
22+
opts = matlab.addons.toolbox.ToolboxOptions(toolboxFolder, identifier);
23+
opts.ToolboxName = "MATLAB Interface to OpenTelemetry";
24+
opts.ToolboxVersion = toolboxVersion;
25+
opts.AuthorName = "MathWorks DevOps Team";
26+
opts.AuthorEmail = "";
27+
28+
% Set the SupportedPlatforms
29+
opts.SupportedPlatforms.Win64 = true;
30+
opts.SupportedPlatforms.Maci64 = true;
31+
opts.SupportedPlatforms.Glnxa64 = true;
32+
opts.SupportedPlatforms.MatlabOnline = false;
33+
34+
opts.MinimumMatlabRelease = "R2022a";
35+
36+
opts.OutputFile = fullfile(outputFolder, "otel-matlab.mltbx");
37+
disp("Output File: " + opts.OutputFile);
38+
matlab.addons.toolbox.packageToolbox(opts);

0 commit comments

Comments
 (0)