Skip to content

Commit d3740df

Browse files
RassKpjanotti
andauthored
Add architecture support for Linux scripts (open-telemetry#3311)
* Add architecture support for Linux scripts * add arm64 script tests --------- Co-authored-by: Paulo Janotti <[email protected]>
1 parent bd58327 commit d3740df

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

.github/workflows/release-publish.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ jobs:
101101
fail-fast: false
102102
matrix:
103103
include:
104-
- base-image: alpine
104+
- machine: ubuntu-20.04
105+
base-image: alpine
105106
net-version: net8.0
106-
- base-image: centos
107+
- machine: ubuntu-20.04
108+
base-image: centos
107109
net-version: net7.0
108-
runs-on: ubuntu-20.04
110+
- machine: actuated-arm64-4cpu-8gb
111+
base-image: alpine
112+
net-version: net8.0
113+
runs-on: ${{ matrix.machine }}
109114
steps:
110115

111116
- name: Checkout

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ uses environment variables as parameters:
191191
|-------------------------|------------------------------------------------------------------|----------|---------------------------|
192192
| `OTEL_DOTNET_AUTO_HOME` | Location where binaries are to be installed | No | `$HOME/.otel-dotnet-auto` |
193193
| `OS_TYPE` | Possible values: `linux-glibc`, `linux-musl`, `macos`, `windows` | No | *Calculated* |
194+
| `ARCHITECTURE` | Possible values for Linux: `x64`, `arm64` | No | *Calculated* |
194195
| `TMPDIR` | Temporary directory used when downloading the files | No | `$(mktemp -d)` |
195196
| `VERSION` | Version to download | No | `1.4.0` |
196197

@@ -202,6 +203,7 @@ uses environment variables as parameters:
202203
| `ENABLE_PROFILING` | Whether to set the .NET CLR Profiler, possible values: `true`, `false` | No | `true` |
203204
| `OTEL_DOTNET_AUTO_HOME` | Location where binaries are to be installed | No | `$HOME/.otel-dotnet-auto` |
204205
| `OS_TYPE` | Possible values: `linux-glibc`, `linux-musl`, `macos`, `windows` | No | *Calculated* |
206+
| `ARCHITECTURE` | Possible values for Linux: `x64`, `arm64` | No | *Calculated* |
205207

206208
### PowerShell module (Windows)
207209

instrument.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,31 @@ if [ -z "$OS_TYPE" ]; then
2020
esac
2121
fi
2222

23+
# guess OS architecture if not provided
24+
if [ -z "$ARCHITECTURE" ]; then
25+
case $(uname -m) in
26+
x86_64) ARCHITECTURE="x64" ;;
27+
aarch64) ARCHITECTURE="arm64" ;;
28+
esac
29+
fi
30+
31+
# validate architecture
32+
case "$ARCHITECTURE" in
33+
"x64"|"arm64")
34+
;;
35+
*)
36+
echo "Set the architecture type using the ARCHITECTURE environment variable. Supported values: x64, arm64." >&2
37+
return 2
38+
;;
39+
esac
40+
2341
# validate input
2442
case "$OS_TYPE" in
2543
"linux-glibc")
26-
DOTNET_RUNTIME_ID="linux-x64"
44+
DOTNET_RUNTIME_ID="linux-$ARCHITECTURE"
2745
;;
2846
"linux-musl")
29-
DOTNET_RUNTIME_ID="linux-musl-x64"
47+
DOTNET_RUNTIME_ID="linux-musl-$ARCHITECTURE"
3048
;;
3149
"macos")
3250
DOTNET_RUNTIME_ID="osx-x64"

script-templates/otel-dotnet-auto-install.sh.template

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,35 @@ case "$OS_TYPE" in
2929
;;
3030
esac
3131

32+
# guess OS architecture if not provided
33+
if [ -z "$ARCHITECTURE" ]; then
34+
case $(uname -m) in
35+
x86_64) ARCHITECTURE="x64" ;;
36+
aarch64) ARCHITECTURE="arm64" ;;
37+
esac
38+
fi
39+
40+
case "$ARCHITECTURE" in
41+
"x64"|"arm64")
42+
;;
43+
*)
44+
echo "Set the architecture type using the ARCHITECTURE environment variable. Supported values: x64, arm64." >&2
45+
exit 1
46+
;;
47+
esac
48+
3249
test -z "$OTEL_DOTNET_AUTO_HOME" && OTEL_DOTNET_AUTO_HOME="$HOME/.otel-dotnet-auto"
3350
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
3451
test -z "$VERSION" && VERSION="v{{VERSION}}"
3552

3653
RELEASES_URL="https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases"
3754
ARCHIVE="opentelemetry-dotnet-instrumentation-$OS_TYPE.zip"
3855

56+
# In case of Linux, use architecture in the download path
57+
if echo "$OS_TYPE" | grep -q "linux"; then
58+
ARCHIVE="opentelemetry-dotnet-instrumentation-$OS_TYPE-$ARCHITECTURE.zip"
59+
fi
60+
3961
TMPFILE="$TMPDIR/$ARCHIVE"
4062
(
4163
cd "$TMPDIR"

0 commit comments

Comments
 (0)