Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: "OpenTelemetry-Matlab"
name: "Build and Run Tests"
on:
workflow_dispatch:
push:
jobs:
build-and-run-tests-ubuntu:
runs-on: ubuntu-latest
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
# Instead, run on ubuntu-20.04
runs-on: ubuntu-20.04
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
SYSTEM_LIBSTDCPP_PATH: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
Expand All @@ -24,11 +26,6 @@ jobs:
cmake --build build --config Release --target install
- name: Run tests
env:
# The version of libstdc++ that is bundled with MATLAB is used when building MEX files.
# This version of libstdc++ is incompatible with the system version of libstdc++.
# As a workaround, set LD_PRELOAD to use the system version of libstdc++ with MATLAB.
LD_PRELOAD: ${{ env.SYSTEM_LIBSTDCPP_PATH }}

# Add the installation directory to the MATLAB Search Path by
# setting the MATLABPATH environment variable.
MATLABPATH: ${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
Expand Down
134 changes: 134 additions & 0 deletions .github/workflows/publish_mltbx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: "Publish mltbx"
on:
workflow_dispatch:
release:
types: published
jobs:
build-ubuntu:
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
# Instead, run on ubuntu-20.04
runs-on: ubuntu-20.04
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
steps:
- name: Download OpenTelemetry-Matlab source
uses: actions/checkout@v3
with:
path: opentelemetry-matlab
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: MATLAB_Compiler
- name: Build OpenTelemetry-Matlab
run: |
cd opentelemetry-matlab
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
cmake --build build --config Release --target install
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-ubuntu.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-ubuntu.tar.gz
path: ${{ github.workspace }}/otel-matlab-ubuntu.tar.gz
build-windows:
runs-on: windows-latest
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
steps:
- name: Download OpenTelemetry-Matlab source
uses: actions/checkout@v3
with:
path: opentelemetry-matlab
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: MATLAB_Compiler
- name: Build OpenTelemetry-Matlab
run: |
cd opentelemetry-matlab
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
cmake --build build --config Release --target install
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-windows.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-windows.tar.gz
path: ${{ github.workspace }}/otel-matlab-windows.tar.gz
build-macos:
runs-on: macos-latest
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
steps:
- name: Download OpenTelemetry-Matlab source
uses: actions/checkout@v3
with:
path: opentelemetry-matlab
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v2
with:
products: MATLAB_Compiler
- name: Build OpenTelemetry-Matlab
run: |
cd opentelemetry-matlab
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
cmake --build build --config Release --target install
- name: Compress into single artifact
working-directory: ${{ github.workspace }}
run: tar -czf otel-matlab-macos.tar.gz otel_matlab_install
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: otel-matlab-macos.tar.gz
path: ${{ github.workspace }}/otel-matlab-macos.tar.gz
package-mltbx:
name: Package MATLAB Toolbox (MLTBX) Files
runs-on: ubuntu-20.04
needs:
- build-ubuntu
- build-windows
- build-macos
env:
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
steps:
- name: Checkout OpenTelemetry-Matlab
uses: actions/checkout@v3
with:
path: OpenTelemetry-Matlab
- name: Read version
id: getversion
working-directory: OpenTelemetry-Matlab
run: echo "version=$(cat VERSION.txt)" >> $GITHUB_OUTPUT
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts-downloaded
- name: Decompress Artifacts
run: |
mv artifacts-downloaded/*/*.tar.gz .
tar -xzvf otel-matlab-ubuntu.tar.gz
tar -xzvf otel-matlab-macos.tar.gz
tar -xzvf otel-matlab-windows.tar.gz
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Run commands
env:
MATLABPATH: OpenTelemetry-Matlab/tools
OTEL_MATLAB_TOOLBOX_FOLDER: otel_matlab_install
OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER:
OTEL_MATLAB_TOOLBOX_VERSION: ${{ steps.getversion.outputs.version }}
uses: matlab-actions/run-command@v1
with:
command: packageMatlabInterface
- name: Compress Asset
run: zip otel-matlab-${{ github.event.release.tag_name }}.mltbx.zip otel-matlab.mltbx
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: https://uploads.github.com/repos/mathworks/OpenTelemetry-Matlab/releases/${{ github.event.release.id }}/assets{?name,label}`
asset_path: ./otel-matlab-${{ github.event.release.tag_name }}.mltbx.zip
asset_name: otel-matlab-${{ github.event.release.tag_name }}.mltbx.zip
asset_content_type: application/zip
27 changes: 18 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ endif()

set(CLIENT_PROJECT_NAME otel-matlab)

project(${CLIENT_PROJECT_NAME} VERSION 0.1.0)
# read version number
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt OTEL_MATLAB_VERSION_RAW)
string(STRIP ${OTEL_MATLAB_VERSION_RAW} OTEL_MATLAB_VERSION)


project(${CLIENT_PROJECT_NAME} VERSION ${OTEL_MATLAB_VERSION})

# ######################################
# libmexclass
Expand Down Expand Up @@ -125,7 +130,7 @@ 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 "e1119ed")
set(OTEL_CPP_GIT_TAG "a799f4a")

if(DEFINED OTEL_CPP_PREFIX)
string(REPLACE "\\" "/" OTEL_CPP_PREFIX ${OTEL_CPP_PREFIX})
Expand Down Expand Up @@ -270,17 +275,16 @@ if(WITH_OTLP_GRPC)
set(OTLP_MACROS ${OTLP_MACROS} "-D WITH_OTLP_GRPC ")
endif()
endif()

# On Windows, suppress a compiler warning about deprecation of result_of
if(WIN32)
set(CUSTOM_CXX_FLAGS -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING)
else()
set(CUSTOM_CXX_FLAGS "")
endif()

if(WIN32)
# On Windows, suppress a compiler warning about deprecation of result_of
set(CUSTOM_CXX_FLAGS -D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING)
# pass in version number
set(OTLP_MACROS ${OTLP_MACROS} /DOTEL_MATLAB_VERSION="${OTEL_MATLAB_VERSION}")
set(OTEL_PROTO_LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(CUSTOM_CXX_FLAGS "")
set(OTLP_MACROS ${OTLP_MACROS} "-D OTEL_MATLAB_VERSION=\"${OTEL_MATLAB_VERSION}\"")
set(OTEL_PROTO_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()

Expand Down Expand Up @@ -412,6 +416,7 @@ set(OTLP_GRPC_EXPORTER_MATLAB_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcSpanExporter.m
${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcMetricExporter.m
${CMAKE_CURRENT_SOURCE_DIR}/exporters/otlp/+opentelemetry/+exporters/+otlp/OtlpGrpcValidator.m)
set(OTLP_MISC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt)

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

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

# Install dependent runtime libraries
set(LIBMEXCLASS_PROXY_INSTALLED_DIR +libmexclass/+proxy)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ MATLAB® interface to [OpenTelemetry™](https://opentelemetry.io/), base
### Status
- 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 All @@ -21,6 +20,13 @@ Requires MATLAB release R2022b or newer
## Installation
Installation instructions

### Installing With Toolbox Package
1. Under "Assets" of a release, download the toolbox package .mltbx file.
2. Start MATLAB.
3. In the Current Folder browser, navigate to the .mltbx file.
4. Right click on the .mltbx file and select "Install".

### Building From Source
Before proceeding, ensure that the below products are installed:
* [MATLAB](https://www.mathworks.com/products/matlab.html)

Expand Down
1 change: 1 addition & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.6.1
4 changes: 1 addition & 3 deletions sdk/common/src/resource.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The MathWorks, Inc.
// Copyright 2023-2024 The MathWorks, Inc.

#include <list>

Expand All @@ -8,8 +8,6 @@
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/nostd/string_view.h"

#define OTEL_MATLAB_VERSION "1.2.0"

namespace common = opentelemetry::common;
namespace nostd = opentelemetry::nostd;

Expand Down
5 changes: 0 additions & 5 deletions test/tmetrics.m
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,6 @@ 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(false, "Asynchronous metrics attributes incorrectly ignored due to issue in opentelemetry-cpp 1.14.0");

countername = "bar";
callback = @callbackWithAttributes;

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

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
3 changes: 2 additions & 1 deletion test/ttrace.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function testBasic(testCase)

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

nameidx = find(resourcekeys == "telemetry.sdk.name");
verifyNotEmpty(testCase, nameidx);
Expand Down
38 changes: 38 additions & 0 deletions tools/packageMatlabInterface.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% packageMatlabInterface.m
% This script packages installed files for OpenTelemetry interface and
% package them into a single .mltbx file. The location of the installed
% files is taken from environment variable OTEL_MATLAB_TOOLBOX_FOLDER and
% the resulting .mltbx file location is taken from environment variable
% OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER.

% Copyright 2024 The MathWorks, Inc.

toolboxFolder = string(getenv("OTEL_MATLAB_TOOLBOX_FOLDER"));
outputFolder = string(getenv("OTEL_MATLAB_TOOLBOX_OUTPUT_FOLDER"));
toolboxVersion = string(getenv("OTEL_MATLAB_TOOLBOX_VERSION"));

% Output folder must exist.
mkdir(outputFolder);

disp("Toolbox Folder: " + toolboxFolder);
disp("Output Folder: " + outputFolder);
disp("Toolbox Version:" + toolboxVersion);

identifier = "dc2cae2f-4f43-4d2c-b6ed-f1a59f0dfcdf";
opts = matlab.addons.toolbox.ToolboxOptions(toolboxFolder, identifier);
opts.ToolboxName = "MATLAB Interface to OpenTelemetry";
opts.ToolboxVersion = toolboxVersion;
opts.AuthorName = "MathWorks DevOps Team";
opts.AuthorEmail = "";

% Set the SupportedPlatforms
opts.SupportedPlatforms.Win64 = true;
opts.SupportedPlatforms.Maci64 = true;
opts.SupportedPlatforms.Glnxa64 = true;
opts.SupportedPlatforms.MatlabOnline = false;

opts.MinimumMatlabRelease = "R2022a";

opts.OutputFile = fullfile(outputFolder, "otel-matlab.mltbx");
disp("Output File: " + opts.OutputFile);
matlab.addons.toolbox.packageToolbox(opts);