Skip to content

Commit e9e4a6f

Browse files
committed
Mac support
1 parent 6e8dbd4 commit e9e4a6f

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ if(WITH_OTLP_HTTP)
120120
if(WIN32)
121121
set(OTLP_MACROS /DWITH_OTLP_HTTP)
122122
else()
123-
set(OTLP_MACROS -D WITH_OTLP_HTTP)
123+
set(OTLP_MACROS "-D WITH_OTLP_HTTP ")
124124
endif()
125125
endif()
126126

127127
if(WITH_OTLP_GRPC)
128128
if(WIN32)
129129
set(OTLP_MACROS ${OTLP_MACROS} /DWITH_OTLP_GRPC)
130130
else()
131-
set(OTLP_MACROS ${OTLP_MACROS} -D WITH_OTLP_GRPC)
131+
set(OTLP_MACROS ${OTLP_MACROS} "-D WITH_OTLP_GRPC ")
132132
endif()
133133
endif()
134134

@@ -145,6 +145,8 @@ if(UNIX AND NOT APPLE AND NOT CYGWIN)
145145
${ABSL_LIBRARIES}
146146
${UPB_LIBRARIES} -Wl,--no-whole-archive)
147147
target_link_options(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PRIVATE ${OPENTELEMETRY_PROXY_LINK_OPTIONS})
148+
elseif(APPLE)
149+
set_target_properties(${OPENTELEMETRY_PROXY_LIBRARY_NAME} PROPERTIES INSTALL_RPATH "@executable_path")
148150
endif()
149151

150152
# Use C++17
@@ -179,6 +181,9 @@ if(WIN32)
179181
elseif(UNIX AND NOT APPLE AND NOT CYGWIN)
180182
FILE(GLOB OTEL_CPP_RUNTIME ${OPENTELEMETRY_CPP_LIBRARY_DIRS}/*.so)
181183
set(OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES ${OTEL_CPP_RUNTIME})
184+
elseif(APPLE)
185+
FILE(GLOB OTEL_CPP_RUNTIME ${OPENTELEMETRY_CPP_LIBRARY_DIRS}/*.dylib)
186+
set(OPENTELEMETRY_PROXY_RUNTIME_LIBRARIES ${OTEL_CPP_RUNTIME})
182187
endif()
183188

184189
# ##############################

test/commonSetupOnce.m

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +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.")
89
testCase.OtelConfigFile = fullfile(fileparts(mfilename("fullpath")), ...
910
"otelcol_config.yml");
10-
testCase.OtelRoot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
11+
otelroot = getenv("OPENTELEMETRY_MATLAB_INSTALL");
12+
assert(~isempty(otelroot), "OPENTELEMETRY_MATLAB_INSTALL environment must be defined.")
13+
testCase.OtelRoot = otelroot;
1114
testCase.JsonFile = "myoutput.json";
1215
testCase.PidFile = "testoutput.txt";
1316

1417
% process definitions
15-
testCase.Otelcol = fullfile(otelcolroot, "otelcol");
18+
testCase.OtelcolName = "otelcol";
1619
if ispc
1720
testCase.ListPid = @(name)"tasklist /fi ""IMAGENAME eq " + name + ".exe""";
1821
testCase.ReadPidList = @(file)readtable(file, "VariableNamingRule", "preserve", "NumHeaderLines", 3, "MultipleDelimsAsOne", true, "Delimiter", " ");
1922
testCase.ExtractPid = @(table)table.Var2;
2023
windows_killroot = string(getenv("WINDOWS_KILL_INSTALL"));
24+
assert(~isempty(windows_killroot), "WINDOWS_KILL_INSTALL environment must be defined.")
2125
testCase.Sigint = @(id)fullfile(windows_killroot,"windows-kill") + " -SIGINT " + id;
2226
testCase.Sigterm = @(id)"taskkill /pid " + id;
2327
elseif isunix && ~ismac
@@ -26,7 +30,19 @@ function commonSetupOnce(testCase)
2630
testCase.ExtractPid = @(table)table.PID;
2731
testCase.Sigint = @(id)"kill " + id; % kill sends a SIGTERM instead of SIGINT but turns out this is sufficient to terminate OTEL collector on Linux
2832
testCase.Sigterm = @(id)"kill " + id;
33+
elseif ismac
34+
testCase.ListPid = @(name)"pgrep -x " + name;
35+
testCase.ReadPidList = @readmatrix;
36+
testCase.ExtractPid = @(x)x; % no-op that returns itself
37+
testCase.Sigint = @(id)"kill -s INT " + id;
38+
testCase.Sigterm = @(id)"kill -s TERM " + id;
39+
if computer == "MACA64"
40+
% only the contrib version of OpenTelemetry Collector is available on Apple silicon
41+
testCase.OtelcolName = "otelcol-contrib";
42+
end
43+
2944
end
45+
testCase.Otelcol = fullfile(otelcolroot, testCase.OtelcolName);
3046

3147
% set up path
3248
testCase.applyFixture(matlab.unittest.fixtures.PathFixture(testCase.OtelRoot));

test/terminateCollector.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function terminateCollector(testCase)
44
%
55
% Copyright 2023 The MathWorks, Inc.
66

7-
system(testCase.ListPid("otelcol") + " > " + testCase.PidFile);
7+
system(testCase.ListPid(testCase.OtelcolName) + " > " + testCase.PidFile);
88
tbl = testCase.ReadPidList(testCase.PidFile);
99
pid = testCase.ExtractPid(tbl);
1010
retry = 0;
@@ -13,8 +13,8 @@ function terminateCollector(testCase)
1313
while ~isempty(pid) && retry < 4
1414
system(testCase.Sigint(pid));
1515
pause(2); % give a little time for the collector to shut down
16-
system(testCase.ListPid("otelcol") + " > " + testCase.PidFile);
16+
system(testCase.ListPid(testCase.OtelcolName) + " > " + testCase.PidFile);
1717
tbl = testCase.ReadPidList(testCase.PidFile);
1818
pid = testCase.ExtractPid(tbl);
1919
retry = retry + 1;
20-
end
20+
end

0 commit comments

Comments
 (0)