Skip to content

Commit 2bddeb8

Browse files
committed
fix a few build and test issues on Linux
1 parent ba7c075 commit 2bddeb8

File tree

7 files changed

+52
-34
lines changed

7 files changed

+52
-34
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ if(WIN32)
126126
${C_ARES_RUNTIME}
127127
${OPENSSL_RUNTIME}
128128
${RE2_RUNTIME})
129+
elseif(UNIX AND NOT APPLE AND NOT CYGWIN)
130+
FILE(GLOB OTEL_CPP_RUNTIME ${OPENTELEMETRY_CPP_LIBRARY_DIRS}/*.so)
131+
set(OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES ${OTEL_CPP_RUNTIME})
129132
endif()
130133

131134
# ##############################
@@ -167,6 +170,4 @@ install(DIRECTORY ${TRACE_SDK_MATLAB_SOURCES} DESTINATION .)
167170
install(DIRECTORY ${OTLP_EXPORTERS_MATLAB_SOURCES} DESTINATION .)
168171

169172
# Install dependent runtime libraries
170-
if(WIN32)
171-
install(FILES ${OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES} DESTINATION +libmexclass/+proxy)
172-
endif()
173+
install(FILES ${OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES} DESTINATION +libmexclass/+proxy)

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
## DISCLAIMERS
5+
## Status
66
- Currently only tracing is supported. Metrics and logs will be in the future.
77
- This package is supported and has been tested on Windows® and Linux®. We will add macOS support in the future.
88

@@ -21,14 +21,7 @@ Installation instructions
2121
Before proceeding, ensure that the below products are installed:
2222
* [MATLAB](https://www.mathworks.com/products/matlab.html)
2323

24-
1. Download, build and install [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp)
25-
```
26-
cd \<opentelemetry-cpp-root>\
27-
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_STANDARD=20 -DWITH_OTLP=TRUE -DWITH_OTLP_HTTP=TRUE -DWITH_OTLP_GRPC=TRUE -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=\<vcpkg_toolchain_file>\
28-
cmake --build build --config Release --target ALL_BUILD
29-
cmake --install build --prefix \<opentelemetry-cpp-installdir>\
30-
```
31-
2. Download vcpkg. Install the following packages:
24+
1. Download [vcpkg](https://vcpkg.io). Install the following packages:
3225
- abseil
3326
- c-ares
3427
- curl
@@ -42,12 +35,19 @@ cmake --install build --prefix \<opentelemetry-cpp-installdir>\
4235
- gtest
4336
- benchmark
4437

38+
2. Download, build and install [OpenTelemetry C++](https://github.com/open-telemetry/opentelemetry-cpp)
39+
```
40+
cd \<opentelemetry-cpp-root>\
41+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_CXX_STANDARD=20 -DWITH_OTLP_HTTP=TRUE -DWITH_OTLP_GRPC=TRUE -DOPENTELEMETRY_INSTALL=ON -DCMAKE_TOOLCHAIN_FILE=\<vcpkg_root>\scripts\buildsystems\vcpkg.cmake
42+
cmake --build build --config Release --target ALL_BUILD
43+
cmake --install build --prefix \<opentelemetry-cpp-installdir>\
44+
```
4545
3. Download OpenTelemetry MATLAB
4646

4747
4. Build and install OpenTelemetry MATLAB
4848
```
4949
cd \<opentelemetry-matlab-root>\
50-
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=\<opentelemetry-matlab-installdir>\ -DCMAKE_TOOLCHAIN_FILE=\<vcpkg_toolchain_file> -DCMAKE_PREFIX_PATH=\<path to opentelemetry-cpp-config.cmake>\
50+
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=\<opentelemetry-matlab-installdir>\ -DCMAKE_TOOLCHAIN_FILE=\<vcpkg_root>\scripts\buildsystems\vcpkg.cmake -DCMAKE_PREFIX_PATH=\<path to opentelemetry-cpp-config.cmake>\
5151
cmake --build build --config Release --target install
5252
5353
```
@@ -80,6 +80,12 @@ otelcol --config \<otelcol-config-yaml>\
8080
```
8181
4. If your collector is configured to display the data, you should see your span displayed.
8282

83+
## Help
84+
To view documentation of individual function, type "help <function_name>". For example,
85+
```
86+
>> help opentelemetry.sdk.trace.TracerProvider
87+
```
88+
8389
## License
8490
The license is available in the License file within this repository
8591

api/baggage/src/BaggageProxy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include "MatlabDataArray.hpp"
1212

13+
#include <list>
14+
1315
namespace libmexclass::opentelemetry {
1416

1517
libmexclass::proxy::MakeResult BaggageProxy::make(const libmexclass::proxy::FunctionArguments& constructor_arguments) {

test/commonTeardown.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ function commonTeardown(testCase)
33
%
44
% Copyright 2023 The MathWorks, Inc.
55

6+
% Terminate Collector if it is still running
7+
terminateCollector(testCase);
8+
69
% On Windows, a command prompt has popped up, remove it as clean up
710
if ispc
811
system(testCase.TestData.list("cmd") + " > " + testCase.TestData.pidfile);
@@ -11,5 +14,9 @@ function commonTeardown(testCase)
1114
system(testCase.TestData.sigterm(pid));
1215
end
1316

14-
delete(testCase.TestData.jsonfile);
15-
delete(testCase.TestData.pidfile);
17+
if exist(testCase.TestData.jsonfile, "file")
18+
delete(testCase.TestData.jsonfile);
19+
end
20+
if exist(testCase.TestData.pidfile, "file")
21+
delete(testCase.TestData.pidfile);
22+
end

test/readJsonResults.m

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,7 @@
33
%
44
% Copyright 2023 The MathWorks, Inc.
55

6-
system(testCase.TestData.list("otelcol") + " > " + testCase.TestData.pidfile);
7-
8-
tbl = testCase.TestData.readlist(testCase.TestData.pidfile);
9-
pid = testCase.TestData.extractPid(tbl);
10-
system(testCase.TestData.sigint(pid));
11-
12-
% check if kill succeeded as it can sporadically fail
13-
system(testCase.TestData.list("otelcol") + " > " + testCase.TestData.pidfile);
14-
tbl = testCase.TestData.readlist(testCase.TestData.pidfile);
15-
pid = testCase.TestData.extractPid(tbl);
16-
retry = 0;
17-
% sometimes kill will fail with a RuntimeError: windows-kill-library: ctrl-routine:findAddress:checkAddressIsNotNull
18-
% in that case, retry up to 3 times
19-
while ~isempty(pid) && retry < 3
20-
system(testCase.TestData.sigint(pid));
21-
tbl = testCase.TestData.readlist(testCase.TestData.pidfile);
22-
pid = testCase.TestData.extractPid(tbl);
23-
retry = retry + 1;
24-
end
6+
terminateCollector(testCase);
257

268
pause(1);
279
assert(exist(testCase.TestData.jsonfile, "file"));

test/tcontextPropagation.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function testExtract(testCase)
3838
tp = opentelemetry.sdk.trace.TracerProvider();
3939
tr = getTracer(tp, "bar");
4040
sp = startSpan(tr, "quux", Context=newcontext);
41+
pause(1);
4142
endSpan(sp);
4243

4344
% perform test comparisons

test/terminateCollector.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function terminateCollector(testCase)
2+
% Terminate OpenTelemetry Collector before reading results or as part of
3+
% cleanup
4+
%
5+
% Copyright 2023 The MathWorks, Inc.
6+
7+
system(testCase.TestData.list("otelcol") + " > " + testCase.TestData.pidfile);
8+
tbl = testCase.TestData.readlist(testCase.TestData.pidfile);
9+
pid = testCase.TestData.extractPid(tbl);
10+
retry = 0;
11+
% sometimes kill will fail with a RuntimeError: windows-kill-library: ctrl-routine:findAddress:checkAddressIsNotNull
12+
% Retry up to 3 times
13+
while ~isempty(pid) && retry < 4
14+
system(testCase.TestData.sigint(pid));
15+
system(testCase.TestData.list("otelcol") + " > " + testCase.TestData.pidfile);
16+
tbl = testCase.TestData.readlist(testCase.TestData.pidfile);
17+
pid = testCase.TestData.extractPid(tbl);
18+
retry = retry + 1;
19+
end

0 commit comments

Comments
 (0)