Skip to content

Commit f59aa11

Browse files
authored
Merge pull request #18 from mathworks/changes_after_v_1_3_0
Changes after v 1 3 0
2 parents a28e450 + 15cfc4c commit f59aa11

File tree

6 files changed

+53
-24
lines changed

6 files changed

+53
-24
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ jobs:
66
build-and-run-tests:
77
runs-on: ubuntu-latest
88
env:
9-
OPENTELEMETRY_CPP_INSTALL: "${{ github.workspace }}/otel_cpp_install"
109
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
11-
OPENTELEMETRY_COLLECTOR_INSTALL: "${{ github.workspace }}/otelcol"
1210
SYSTEM_LIBSTDCPP_PATH: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
1311
steps:
1412
- name: Download OpenTelemetry-Matlab source
@@ -17,11 +15,6 @@ jobs:
1715
path: opentelemetry-matlab
1816
- name: Install MATLAB
1917
uses: matlab-actions/setup-matlab@v1
20-
- name: Download OpenTelemetry Collector binary
21-
run: |
22-
mkdir otelcol && cd otelcol
23-
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.75.0/otelcol_0.75.0_linux_amd64.tar.gz
24-
tar -xzf otelcol_0.75.0_linux_amd64.tar.gz
2518
- name: Build OpenTelemetry-Matlab
2619
run: |
2720
cd opentelemetry-matlab

test/commonSetupOnce.m

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ function commonSetupOnce(testCase)
55

66
% file definitions
77
otelcolroot = getenv("OPENTELEMETRY_COLLECTOR_INSTALL");
8-
assert(~isempty(otelcolroot), "OPENTELEMETRY_COLLECTOR_INSTALL environment must be defined.")
98
testCase.OtelConfigFile = fullfile(fileparts(mfilename("fullpath")), ...
109
"otelcol_config.yml");
1110
otelroot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
12-
assert(~isempty(otelroot), "OPENTELEMETRY_MATLAB_INSTALL environment must be defined.")
13-
testCase.OtelRoot = otelroot;
1411
testCase.JsonFile = "myoutput.json";
1512
testCase.PidFile = "testoutput.txt";
1613

1714
% process definitions
18-
testCase.OtelcolName = "otelcol";
1915
if ispc
2016
testCase.ListPid = @(name)"tasklist /fi ""IMAGENAME eq " + name + ".exe""";
2117
testCase.ReadPidList = @(file)readtable(file, "VariableNamingRule", "preserve", "NumHeaderLines", 3, "MultipleDelimsAsOne", true, "Delimiter", " ");
22-
testCase.ExtractPid = @(table)table.Var2;
18+
testCase.ExtractPid = @(table)table.Var2;
19+
20+
% variables to support downloading OpenTelemetry Collector
21+
otelcol_arch_name = "windows_amd64";
22+
otelcol_exe_ext = ".exe";
23+
24+
% windows_kill
2325
windows_killroot = getenv("WINDOWS_KILL_INSTALL");
2426
windows_killname = "windows-kill";
2527
if isempty(windows_killroot)
@@ -41,22 +43,58 @@ function commonSetupOnce(testCase)
4143
testCase.ExtractPid = @(table)table.PID;
4244
testCase.Sigint = @(id)"kill " + id; % kill sends a SIGTERM instead of SIGINT but turns out this is sufficient to terminate OTEL collector on Linux
4345
testCase.Sigterm = @(id)"kill " + id;
46+
47+
% variables to support downloading OpenTelemetry Collector
48+
otelcol_arch_name = "linux_amd64";
49+
otelcol_exe_ext = "";
4450
elseif ismac
4551
testCase.ListPid = @(name)"pgrep -x " + name;
4652
testCase.ReadPidList = @readmatrix;
4753
testCase.ExtractPid = @(x)x; % no-op that returns itself
4854
testCase.Sigint = @(id)"kill -s INT " + id;
4955
testCase.Sigterm = @(id)"kill -s TERM " + id;
5056
if computer == "MACA64"
51-
% only the contrib version of OpenTelemetry Collector is available on Apple silicon
52-
testCase.OtelcolName = "otelcol-contrib";
57+
otelcol_arch_name = "darwin_arm64";
58+
else
59+
otelcol_arch_name = "darwin_amd64";
5360
end
61+
otelcol_exe_ext = "";
62+
63+
end
5464

65+
% OpenTelemetry Collector
66+
otelcolname = "otelcol";
67+
if isempty(otelcolroot)
68+
% collector not pre-installed
69+
otelcol_version = "0.85.0";
70+
otelcol_url = "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v" ...
71+
+ otelcol_version;
72+
otelcol_zipfilename = "otelcol_" + otelcol_version + "_" + otelcol_arch_name;
73+
otelcolroot = fullfile(tempdir, otelcol_zipfilename);
74+
75+
% look for it in tempdir, download and install if it doesn't exist
76+
if ~(exist(fullfile(otelcolroot, otelcolname + otelcol_exe_ext),"file") || ...
77+
exist(fullfile(otelcolroot,otelcolname + "-contrib" + otelcol_exe_ext),"file"))
78+
% download and install
79+
otelcol_tar = gunzip(fullfile(otelcol_url, otelcol_zipfilename + ".tar.gz"), otelcolroot);
80+
otelcol_tar = otelcol_tar{1}; % should have only extracted 1 tar file
81+
untar(otelcol_tar, otelcolroot);
82+
delete(otelcol_tar);
83+
end
84+
end
85+
% check for contrib version
86+
if exist(fullfile(otelcolroot,otelcolname + "-contrib" + otelcol_exe_ext),"file")
87+
testCase.OtelcolName = otelcolname + "-contrib";
88+
else
89+
testCase.OtelcolName = otelcolname;
5590
end
91+
5692
testCase.Otelcol = fullfile(otelcolroot, testCase.OtelcolName);
5793

5894
% set up path
59-
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(testCase.OtelRoot));
95+
if ~isempty(otelroot)
96+
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(otelroot));
97+
end
6098

6199
% remove temporary files if present
62100
if exist(testCase.JsonFile, "file")

test/performance/traceTest.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
properties
55
OtelConfigFile
6-
OtelRoot
76
JsonFile
87
PidFile
9-
OtelcolName
8+
OtelcolName
109
Otelcol
1110
ListPid
1211
ReadPidList

test/tbaggage.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
% Copyright 2023 The MathWorks, Inc.
55

66
properties
7-
OtelRoot
87
BaggageKeys
98
BaggageValues
109
BaggageHeaders
1110
end
1211

1312
methods (TestClassSetup)
1413
function setupOnce(testCase)
15-
testCase.OtelRoot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
14+
otelroot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
1615

1716
% set up path
18-
addpath(testCase.OtelRoot);
17+
if ~isempty(otelroot)
18+
addpath(otelroot);
19+
end
1920

2021
testCase.BaggageKeys = ["userId", "serverNode", "isProduction"];
2122
testCase.BaggageValues = ["alice", "DF28", "false"];

test/tcontextPropagation.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
properties
77
OtelConfigFile
8-
OtelRoot
98
JsonFile
109
PidFile
11-
OtelcolName
10+
OtelcolName
1211
Otelcol
1312
ListPid
1413
ReadPidList

test/ttrace.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
properties
77
OtelConfigFile
8-
OtelRoot
98
JsonFile
109
PidFile
11-
OtelcolName
10+
OtelcolName
1211
Otelcol
1312
ListPid
1413
ReadPidList

0 commit comments

Comments
 (0)