Skip to content

Commit 25722e2

Browse files
committed
Merge branch 'main' into testing
2 parents b4db5ff + 0267d62 commit 25722e2

File tree

65 files changed

+1774
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1774
-142
lines changed

.github/workflows/build_and_test_full.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
MLM_LICENSE_TOKEN: ${{ secrets.MLM_LICENSE_TOKEN }}
1010
jobs:
1111
get_version:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
outputs:
1414
version: ${{ steps.getversion.outputs.latest_tag }}
1515
steps:
@@ -25,9 +25,7 @@ jobs:
2525
working-directory: opentelemetry-matlab
2626
run: echo "latest_tag=$(sed -re 's/^v?([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)?.*/\1/' <<< $(git describe --tags --abbrev=0))" >> $GITHUB_OUTPUT
2727
build-and-run-tests-ubuntu:
28-
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
29-
# Instead, run on ubuntu-20.04
30-
runs-on: ubuntu-20.04
28+
runs-on: ubuntu-22.04
3129
needs: get_version
3230
env:
3331
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
@@ -57,9 +55,7 @@ jobs:
5755
with:
5856
select-by-folder: opentelemetry-matlab/test
5957
code-coverage-build-and-run-tests-ubuntu:
60-
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
61-
# Instead, run on ubuntu-20.04
62-
runs-on: ubuntu-20.04
58+
runs-on: ubuntu-22.04
6359
needs: get_version
6460
env:
6561
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"

.github/workflows/build_and_test_simple.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
MLM_LICENSE_TOKEN: ${{ secrets.MLM_LICENSE_TOKEN }}
1111
jobs:
1212
get_version:
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-22.04
1414
outputs:
1515
version: ${{ steps.getversion.outputs.latest_tag }}
1616
steps:
@@ -26,9 +26,7 @@ jobs:
2626
working-directory: opentelemetry-matlab
2727
run: echo "latest_tag=$(sed -re 's/^v?([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)?.*/\1/' <<< $(git describe --tags --abbrev=0))" >> $GITHUB_OUTPUT
2828
build-and-run-tests-ubuntu:
29-
# Running on ubuntu-latest would use a glibc version that is incompatible when using the built mex files on a Debian 11
30-
# Instead, run on ubuntu-20.04
31-
runs-on: ubuntu-20.04
29+
runs-on: ubuntu-22.04
3230
needs: get_version
3331
env:
3432
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"

.github/workflows/create_release.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ on:
55
- '[0-9]+.[0-9]+.[0-9]+'
66
jobs:
77
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
8+
runs-on: ubuntu-22.04
119
env:
1210
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
1311
steps:
@@ -24,7 +22,7 @@ jobs:
2422
- name: Build OpenTelemetry-Matlab
2523
working-directory: opentelemetry-matlab
2624
run: |
27-
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP_GRPC=ON -DOTEL_MATLAB_VERSION=${{ github.ref_name }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
25+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP_GRPC=ON -DWITH_OTLP_FILE=ON -DOTEL_MATLAB_VERSION=${{ github.ref_name }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
2826
cmake --build build --config Release --target install
2927
- name: Compress into single artifact
3028
working-directory: ${{ github.workspace }}
@@ -54,7 +52,7 @@ jobs:
5452
shell: cmd
5553
run: |
5654
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
57-
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP_GRPC=ON -DFETCH_VCPKG=ON -DOTEL_MATLAB_VERSION=${{ github.ref_name }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
55+
cmake -S . -B build -G Ninja -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP_GRPC=ON -DWITH_OTLP_FILE=ON -DFETCH_VCPKG=ON -DOTEL_MATLAB_VERSION=${{ github.ref_name }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
5856
cmake --build build --config Release --target install
5957
- name: Compress into single artifact
6058
working-directory: ${{ github.workspace }}
@@ -85,7 +83,7 @@ jobs:
8583
- name: Build OpenTelemetry-Matlab
8684
working-directory: opentelemetry-matlab
8785
run: |
88-
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_GRPC=ON -DOTEL_MATLAB_VERSION=${{ github.ref_name }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
86+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DWITH_OTLP_GRPC=ON -DWITH_OTLP_FILE=ON -DOTEL_MATLAB_VERSION=${{ github.ref_name }} -DCMAKE_INSTALL_PREFIX=${{ env.OPENTELEMETRY_MATLAB_INSTALL }}
8987
cmake --build build --config Release --target install
9088
- name: Compress into single artifact
9189
working-directory: ${{ github.workspace }}
@@ -97,7 +95,7 @@ jobs:
9795
path: ${{ github.workspace }}/otel-matlab-${{ matrix.os }}.tar.gz
9896
package-mltbx:
9997
name: Package MATLAB Toolbox (MLTBX) Files
100-
runs-on: ubuntu-20.04
98+
runs-on: ubuntu-22.04
10199
permissions:
102100
contents: write
103101
needs:

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,13 @@ if(NOT DEFINED OTEL_CPP_INSTALLED_DIR)
191191
include(ExternalProject)
192192
set(OTEL_CPP_PROJECT_NAME opentelemetry-cpp)
193193
set(OTEL_CPP_GIT_REPOSITORY "https://github.com/open-telemetry/opentelemetry-cpp.git")
194-
set(OTEL_CPP_GIT_TAG "fa0a520")
194+
set(OTEL_CPP_GIT_TAG "955a807")
195195

196196
set(OTEL_CPP_CXX_STANDARD 14)
197197

198+
# The synchronous gauge metric instrument is only defined in ABI version 2
199+
set(OTEL_CPP_ABI_VERSION OPENTELEMETRY_ABI_VERSION_NO=2)
200+
198201
set(PATCHES_DIR ${CMAKE_SOURCE_DIR}/patches)
199202
if(SKIP_OTEL_CPP_PATCH)
200203
set(patch_comand "")
@@ -209,14 +212,16 @@ if(NOT DEFINED OTEL_CPP_INSTALLED_DIR)
209212
set(patch_command "")
210213
endif()
211214

215+
# Note: examples are temporarily turned off (-DWITH_EXAMPLES=OFF) due to a build issue that is now fixed in #3284
216+
# Renable examples after pulling in the fix
212217
ExternalProject_Add(
213218
${OTEL_CPP_PROJECT_NAME}
214219
GIT_REPOSITORY ${OTEL_CPP_GIT_REPOSITORY}
215220
GIT_TAG ${OTEL_CPP_GIT_TAG}
216221
PREFIX ${OTEL_CPP_PREFIX}
217222
UPDATE_DISCONNECTED 1
218223
PATCH_COMMAND ${patch_command}
219-
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DWITH_OTLP_HTTP=${WITH_OTLP_HTTP} -DWITH_OTLP_GRPC=${WITH_OTLP_GRPC} -DWITH_OTLP_FILE=${WITH_OTLP_FILE} -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_CXX_STANDARD=${OTEL_CPP_CXX_STANDARD} -DVCPKG_INSTALLED_DIR=${VCPKG_INSTALLED_DIR} ${TRIPLET_DEFINITIONS}
224+
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DWITH_ABI_VERSION_1=OFF -DWITH_ABI_VERSION_2=ON -DWITH_OTLP_HTTP=${WITH_OTLP_HTTP} -DWITH_OTLP_GRPC=${WITH_OTLP_GRPC} -DWITH_OTLP_FILE=${WITH_OTLP_FILE} -DWITH_EXAMPLES=OFF -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_CXX_STANDARD=${OTEL_CPP_CXX_STANDARD} -DVCPKG_INSTALLED_DIR=${VCPKG_INSTALLED_DIR} ${TRIPLET_DEFINITIONS}
220225
BUILD_BYPRODUCTS ${OTEL_CPP_LIBRARIES}
221226
INSTALL_DIR ${OTEL_CPP_PREFIX}
222227
INSTALL_COMMAND ${CMAKE_COMMAND} --install . --prefix ${OTEL_CPP_PREFIX} --config $<CONFIG>
@@ -291,6 +296,7 @@ set(OPENTELEMETRY_PROXY_SOURCES
291296
${METRICS_API_SOURCE_DIR}/CounterProxy.cpp
292297
${METRICS_API_SOURCE_DIR}/UpDownCounterProxy.cpp
293298
${METRICS_API_SOURCE_DIR}/HistogramProxy.cpp
299+
${METRICS_API_SOURCE_DIR}/GaugeProxy.cpp
294300
${METRICS_API_SOURCE_DIR}/SynchronousInstrumentProxyFactory.cpp
295301
${METRICS_API_SOURCE_DIR}/MeasurementFetcher.cpp
296302
${METRICS_API_SOURCE_DIR}/AsynchronousInstrumentProxy.cpp
@@ -365,6 +371,8 @@ if(WITH_OTLP_FILE)
365371
target_compile_definitions(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE WITH_OTLP_FILE)
366372
endif()
367373

374+
target_compile_definitions(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OTEL_CPP_ABI_VERSION})
375+
368376
# pass in version number
369377
target_compile_definitions(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE OTEL_MATLAB_VERSION="${OTEL_MATLAB_VERSION}")
370378
if(WIN32)

OtelMatlabProxyFactory.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023-2024 The MathWorks, Inc.
1+
// Copyright 2023-2025 The MathWorks, Inc.
22

33
#include "OtelMatlabProxyFactory.h"
44

@@ -8,7 +8,10 @@
88
//#include "opentelemetry-matlab/trace/ScopeProxy.h"
99
#include "opentelemetry-matlab/trace/SpanContextProxy.h"
1010
#include "opentelemetry-matlab/trace/TraceContextPropagatorProxy.h"
11+
#include "opentelemetry-matlab/trace/NoOpTracerProviderProxy.h"
12+
#include "opentelemetry-matlab/metrics/NoOpMeterProviderProxy.h"
1113
#include "opentelemetry-matlab/logs/LoggerProviderProxy.h"
14+
#include "opentelemetry-matlab/logs/NoOpLoggerProviderProxy.h"
1215
#include "opentelemetry-matlab/context/propagation/TextMapCarrierProxy.h"
1316
#include "opentelemetry-matlab/context/propagation/TextMapPropagatorProxy.h"
1417
#include "opentelemetry-matlab/context/propagation/CompositePropagatorProxy.h"
@@ -57,6 +60,9 @@ OtelMatlabProxyFactory::make_proxy(const libmexclass::proxy::ClassName& class_na
5760
REGISTER_PROXY(libmexclass.opentelemetry.SpanProxy, libmexclass::opentelemetry::SpanProxy);
5861
//REGISTER_PROXY(libmexclass.opentelemetry.ScopeProxy, libmexclass::opentelemetry::ScopeProxy);
5962
REGISTER_PROXY(libmexclass.opentelemetry.SpanContextProxy, libmexclass::opentelemetry::SpanContextProxy);
63+
REGISTER_PROXY(libmexclass.opentelemetry.NoOpTracerProviderProxy, libmexclass::opentelemetry::NoOpTracerProviderProxy);
64+
REGISTER_PROXY(libmexclass.opentelemetry.NoOpMeterProviderProxy, libmexclass::opentelemetry::NoOpMeterProviderProxy);
65+
REGISTER_PROXY(libmexclass.opentelemetry.NoOpLoggerProviderProxy, libmexclass::opentelemetry::NoOpLoggerProviderProxy);
6066
REGISTER_PROXY(libmexclass.opentelemetry.TextMapCarrierProxy, libmexclass::opentelemetry::TextMapCarrierProxy);
6167
REGISTER_PROXY(libmexclass.opentelemetry.ContextProxy, libmexclass::opentelemetry::ContextProxy);
6268
REGISTER_PROXY(libmexclass.opentelemetry.TokenProxy, libmexclass::opentelemetry::TokenProxy);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
classdef NoOpLoggerProvider < handle
2+
% A no-op logger provider does nothing and is used to disable logging.
3+
% For internal use only.
4+
5+
% Copyright 2025 The MathWorks, Inc.
6+
7+
properties (Access=private)
8+
Proxy % Proxy object to interface C++ code
9+
end
10+
11+
methods (Access=?opentelemetry.logs.Provider)
12+
function obj = NoOpLoggerProvider()
13+
% constructs a no-op LoggerProvider and sets it as the global
14+
% instance
15+
obj.Proxy = libmexclass.proxy.Proxy("Name", ...
16+
"libmexclass.opentelemetry.NoOpLoggerProviderProxy", ...
17+
"ConstructorArguments", {});
18+
end
19+
end
20+
end

api/logs/+opentelemetry/+logs/Logger.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef Logger < handle
22
% A logger that is used to emit log records
33

4-
% Copyright 2024 The MathWorks, Inc.
4+
% Copyright 2024-2025 The MathWorks, Inc.
55

66
properties (SetAccess=immutable)
77
Name (1,1) string % Logger name
@@ -38,7 +38,9 @@ function emitLogRecord(obj, severity, body, trailingnames, trailingvalues)
3838
% Parameters are:
3939
% "Context" - Span contained in a context object.
4040
% "Timestamp" - Timestamp of the log record specified as a
41-
% datetime. Default is the current time.
41+
% datetime. Default is the current time. If
42+
% Timestamp does not have a time zone
43+
% specified, it is interpreted as a UTC time.
4244
% "Attributes" - Attribute name-value pairs specified as
4345
% a dictionary.
4446
%

api/logs/+opentelemetry/+logs/Provider.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef Provider
22
% Get and set the global instance of logger provider
33

4-
% Copyright 2024 The MathWorks, Inc.
4+
% Copyright 2024-2025 The MathWorks, Inc.
55

66
methods (Static)
77
function p = getLoggerProvider()
@@ -19,10 +19,22 @@ function setLoggerProvider(p)
1919
% OPENTELEMETRY.LOGS.PROVIDER.SETLOGGERPROVIDER(LP) sets
2020
% LP as the global instance of logger provider.
2121
%
22-
% See also OPENTELEMETRY.LOGS.PROVIDER.GETTRACERPROVIDER
22+
% See also OPENTELEMETRY.LOGS.PROVIDER.GETLOGGERPROVIDER,
23+
% OPENTELEMETRY.LOGS.PROVIDER.UNSETLOGGERPROVIDER
2324

2425
p.setLoggerProvider();
2526
end
27+
28+
function unsetLoggerProvider()
29+
% Unset the global instance of logger provider, which disables
30+
% logging
31+
% OPENTELEMETRY.LOGS.PROVIDER.UNSETLOGGERPROVIDER() unsets
32+
% the global instance of logger provider.
33+
%
34+
% See also OPENTELEMETRY.LOGS.PROVIDER.SETLOGGERPROVIDER
35+
36+
opentelemetry.logs.internal.NoOpLoggerProvider;
37+
end
2638
end
2739

2840
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2025 The MathWorks, Inc.
2+
3+
#pragma once
4+
5+
#include "libmexclass/proxy/Proxy.h"
6+
7+
#include "opentelemetry/logs/logger_provider.h"
8+
#include "opentelemetry/logs/provider.h"
9+
#include "opentelemetry/logs/noop.h"
10+
11+
namespace logs_api = opentelemetry::logs;
12+
namespace nostd = opentelemetry::nostd;
13+
14+
namespace libmexclass::opentelemetry {
15+
class NoOpLoggerProviderProxy : public libmexclass::proxy::Proxy {
16+
public:
17+
NoOpLoggerProviderProxy(nostd::shared_ptr<logs_api::LoggerProvider> lp) : CppLoggerProvider(lp) {
18+
// set as global LoggerProvider instance
19+
logs_api::Provider::SetLoggerProvider(CppLoggerProvider);
20+
}
21+
22+
static libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments) {
23+
return std::make_shared<NoOpLoggerProviderProxy>(nostd::shared_ptr<logs_api::LoggerProvider>(new logs_api::NoopLoggerProvider()));
24+
}
25+
26+
protected:
27+
nostd::shared_ptr<logs_api::LoggerProvider> CppLoggerProvider;
28+
};
29+
} // namespace libmexclass::opentelemetry

api/logs/src/LoggerProxy.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "opentelemetry/logs/log_record.h"
1010
#include "opentelemetry/trace/context.h"
1111
#include "opentelemetry/context/context.h"
12+
#include "opentelemetry/common/timestamp.h"
1213

1314
#include "MatlabDataArray.hpp"
1415

@@ -40,6 +41,12 @@ void LoggerProxy::emitLogRecord(libmexclass::proxy::method::Context& context) {
4041

4142
nostd::unique_ptr<logs_api::LogRecord> rec = CppLogger->CreateLogRecord();
4243

44+
// Do not use the default timestamp, which is set to the start of UNIX epoch. Set both the
45+
// default timestamp and default observed timestamp to the current time
46+
auto now = common::SystemTimestamp(std::chrono::system_clock::now());
47+
rec->SetTimestamp(now);
48+
rec->SetObservedTimestamp(now);
49+
4350
// Add size attribute if body is nonscalar
4451
if (array_body) {
4552
rec->SetAttribute(bodyattrs.Attributes.back().first, bodyattrs.Attributes.back().second);

0 commit comments

Comments
 (0)