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
7 changes: 0 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ jobs:
build-and-run-tests:
runs-on: ubuntu-latest
env:
OPENTELEMETRY_CPP_INSTALL: "${{ github.workspace }}/otel_cpp_install"
OPENTELEMETRY_MATLAB_INSTALL: "${{ github.workspace }}/otel_matlab_install"
OPENTELEMETRY_COLLECTOR_INSTALL: "${{ github.workspace }}/otelcol"
SYSTEM_LIBSTDCPP_PATH: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
steps:
- name: Download OpenTelemetry-Matlab source
Expand All @@ -17,11 +15,6 @@ jobs:
path: opentelemetry-matlab
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Download OpenTelemetry Collector binary
run: |
mkdir otelcol && cd otelcol
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.75.0/otelcol_0.75.0_linux_amd64.tar.gz
tar -xzf otelcol_0.75.0_linux_amd64.tar.gz
- name: Build OpenTelemetry-Matlab
run: |
cd opentelemetry-matlab
Expand Down
54 changes: 46 additions & 8 deletions test/commonSetupOnce.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ function commonSetupOnce(testCase)

% file definitions
otelcolroot = getenv("OPENTELEMETRY_COLLECTOR_INSTALL");
assert(~isempty(otelcolroot), "OPENTELEMETRY_COLLECTOR_INSTALL environment must be defined.")
testCase.OtelConfigFile = fullfile(fileparts(mfilename("fullpath")), ...
"otelcol_config.yml");
otelroot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
assert(~isempty(otelroot), "OPENTELEMETRY_MATLAB_INSTALL environment must be defined.")
testCase.OtelRoot = otelroot;
testCase.JsonFile = "myoutput.json";
testCase.PidFile = "testoutput.txt";

% process definitions
testCase.OtelcolName = "otelcol";
if ispc
testCase.ListPid = @(name)"tasklist /fi ""IMAGENAME eq " + name + ".exe""";
testCase.ReadPidList = @(file)readtable(file, "VariableNamingRule", "preserve", "NumHeaderLines", 3, "MultipleDelimsAsOne", true, "Delimiter", " ");
testCase.ExtractPid = @(table)table.Var2;
testCase.ExtractPid = @(table)table.Var2;

% variables to support downloading OpenTelemetry Collector
otelcol_arch_name = "windows_amd64";
otelcol_exe_ext = ".exe";

% windows_kill
windows_killroot = getenv("WINDOWS_KILL_INSTALL");
windows_killname = "windows-kill";
if isempty(windows_killroot)
Expand All @@ -41,22 +43,58 @@ function commonSetupOnce(testCase)
testCase.ExtractPid = @(table)table.PID;
testCase.Sigint = @(id)"kill " + id; % kill sends a SIGTERM instead of SIGINT but turns out this is sufficient to terminate OTEL collector on Linux
testCase.Sigterm = @(id)"kill " + id;

% variables to support downloading OpenTelemetry Collector
otelcol_arch_name = "linux_amd64";
otelcol_exe_ext = "";
elseif ismac
testCase.ListPid = @(name)"pgrep -x " + name;
testCase.ReadPidList = @readmatrix;
testCase.ExtractPid = @(x)x; % no-op that returns itself
testCase.Sigint = @(id)"kill -s INT " + id;
testCase.Sigterm = @(id)"kill -s TERM " + id;
if computer == "MACA64"
% only the contrib version of OpenTelemetry Collector is available on Apple silicon
testCase.OtelcolName = "otelcol-contrib";
otelcol_arch_name = "darwin_arm64";
else
otelcol_arch_name = "darwin_amd64";
end
otelcol_exe_ext = "";

end

% OpenTelemetry Collector
otelcolname = "otelcol";
if isempty(otelcolroot)
% collector not pre-installed
otelcol_version = "0.85.0";
otelcol_url = "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v" ...
+ otelcol_version;
otelcol_zipfilename = "otelcol_" + otelcol_version + "_" + otelcol_arch_name;
otelcolroot = fullfile(tempdir, otelcol_zipfilename);

% look for it in tempdir, download and install if it doesn't exist
if ~(exist(fullfile(otelcolroot, otelcolname + otelcol_exe_ext),"file") || ...
exist(fullfile(otelcolroot,otelcolname + "-contrib" + otelcol_exe_ext),"file"))
% download and install
otelcol_tar = gunzip(fullfile(otelcol_url, otelcol_zipfilename + ".tar.gz"), otelcolroot);
otelcol_tar = otelcol_tar{1}; % should have only extracted 1 tar file
untar(otelcol_tar, otelcolroot);
delete(otelcol_tar);
end
end
% check for contrib version
if exist(fullfile(otelcolroot,otelcolname + "-contrib" + otelcol_exe_ext),"file")
testCase.OtelcolName = otelcolname + "-contrib";
else
testCase.OtelcolName = otelcolname;
end

testCase.Otelcol = fullfile(otelcolroot, testCase.OtelcolName);

% set up path
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(testCase.OtelRoot));
if ~isempty(otelroot)
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(otelroot));
end

% remove temporary files if present
if exist(testCase.JsonFile, "file")
Expand Down
3 changes: 1 addition & 2 deletions test/performance/traceTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

properties
OtelConfigFile
OtelRoot
JsonFile
PidFile
OtelcolName
OtelcolName
Otelcol
ListPid
ReadPidList
Expand Down
7 changes: 4 additions & 3 deletions test/tbaggage.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
% Copyright 2023 The MathWorks, Inc.

properties
OtelRoot
BaggageKeys
BaggageValues
BaggageHeaders
end

methods (TestClassSetup)
function setupOnce(testCase)
testCase.OtelRoot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
otelroot = getenv("OPENTELEMETRY_MATLAB_INSTALL");

% set up path
addpath(testCase.OtelRoot);
if ~isempty(otelroot)
addpath(otelroot);
end

testCase.BaggageKeys = ["userId", "serverNode", "isProduction"];
testCase.BaggageValues = ["alice", "DF28", "false"];
Expand Down
3 changes: 1 addition & 2 deletions test/tcontextPropagation.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

properties
OtelConfigFile
OtelRoot
JsonFile
PidFile
OtelcolName
OtelcolName
Otelcol
ListPid
ReadPidList
Expand Down
3 changes: 1 addition & 2 deletions test/ttrace.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

properties
OtelConfigFile
OtelRoot
JsonFile
PidFile
OtelcolName
OtelcolName
Otelcol
ListPid
ReadPidList
Expand Down