diff --git a/VERSION b/VERSION index f6f0695e5..b29328632 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.12.5 +4.12.6 diff --git a/src/usr/share/opentelemetry_shell/opentelemetry_shell.custom.docker.sh b/src/usr/share/opentelemetry_shell/opentelemetry_shell.custom.docker.sh index 592cc098a..94f220154 100755 --- a/src/usr/share/opentelemetry_shell/opentelemetry_shell.custom.docker.sh +++ b/src/usr/share/opentelemetry_shell/opentelemetry_shell.custom.docker.sh @@ -59,8 +59,8 @@ _otel_inject_docker_args() { \echo -n ' '; _otel_escape_args --mount type=bind,source="$_otel_remote_sdk_pipe",target=/var/opentelemetry_shell"$_otel_remote_sdk_pipe" \echo -n ' '; _otel_escape_args --env OTEL_REMOTE_SDK_PIPE=/var/opentelemetry_shell"$_otel_remote_sdk_pipe" local pipes_dir="$(\mktemp -u)_opentelemetry_shell_$$.docker/tmp"; \mkdir -p "$pipes_dir" - \echo -n ' '; _otel_escape_args --mount type=bind,source="$pipes_dir",target=/tmp - \echo -n ' '; _otel_escape_args --env OTEL_SHELL_RESPONSE_PIPE_MOUNT="$pipes_dir/.."; + \echo -n ' '; _otel_escape_args --mount type=bind,source="$pipes_dir",target="$pipes_dir" + \echo -n ' '; _otel_escape_args --env OTEL_SHELL_RESPONSE_PIPE_MOUNT="$pipes_dir"; \echo -n ' '; _otel_escape_args --env OTEL_SHELL_AUTO_INJECTED=TRUE \echo -n ' '; _otel_escape_args --env OTEL_SHELL_AUTO_INSTRUMENTATION_HINT="$("$executable" inspect "$image" | \jq -r '.[0].Config.Entrypoint[]?')" \echo -n ' '; _otel_escape_args --entrypoint /bin/sh diff --git a/src/usr/share/opentelemetry_shell/opentelemetry_shell_api.sh b/src/usr/share/opentelemetry_shell/opentelemetry_shell_api.sh index 0d2f0aa88..b67551200 100755 --- a/src/usr/share/opentelemetry_shell/opentelemetry_shell_api.sh +++ b/src/usr/share/opentelemetry_shell/opentelemetry_shell_api.sh @@ -15,6 +15,7 @@ fi # basic setup _otel_remote_sdk_pipe="${OTEL_REMOTE_SDK_PIPE:-$(\mktemp -u)_opentelemetry_shell_$$.pipe}" +if \[ -z "$OTEL_SHELL_RESPONSE_PIPE_MOUNT" ]; then OTEL_SHELL_RESPONSE_PIPE_MOUNT=/tmp; fi _otel_shell="$(\readlink "/proc/$$/exe" | \rev | \cut -d / -f 1 | \rev)" if \[ "$OTEL_SHELL_COMMANDLINE_OVERRIDE_SIGNATURE" = 0 ] || \[ "$OTEL_SHELL_COMMANDLINE_OVERRIDE_SIGNATURE" = "$PPID" ] || \[ "$PPID" = 0 ] || \[ "$(\tr '\000-\037' ' ' < /proc/$PPID/cmdline)" = "$(\tr '\000-\037' ' ' < /proc/$OTEL_SHELL_COMMANDLINE_OVERRIDE_SIGNATURE/cmdline)" ]; then _otel_commandline_override="$OTEL_SHELL_COMMANDLINE_OVERRIDE"; fi unset OTEL_SHELL_COMMANDLINE_OVERRIDE @@ -129,9 +130,9 @@ _otel_resolve_package_version() { } otel_span_current() { - local response_pipe="$(\mktemp -u)_opentelemetry_shell_$$.pipe" + local response_pipe="$(\mktemp -u -p "$OTEL_SHELL_RESPONSE_PIPE_MOUNT")_opentelemetry_shell_$$.pipe" \mkfifo $_otel_mkfifo_flags "$response_pipe" - _otel_sdk_communicate "SPAN_HANDLE" "$OTEL_SHELL_RESPONSE_PIPE_MOUNT/$response_pipe" "$OTEL_TRACEPARENT" + _otel_sdk_communicate "SPAN_HANDLE" "$response_pipe" "$OTEL_TRACEPARENT" \cat "$response_pipe" \rm "$response_pipe" &> /dev/null } @@ -139,9 +140,9 @@ otel_span_current() { otel_span_start() { local kind="$1" local name="$2" - local response_pipe="$(\mktemp -u)_opentelemetry_shell_$$.pipe" + local response_pipe="$(\mktemp -u -p "$OTEL_SHELL_RESPONSE_PIPE_MOUNT")_opentelemetry_shell_$$.pipe" \mkfifo $_otel_mkfifo_flags "$response_pipe" - _otel_sdk_communicate "SPAN_START" "$OTEL_SHELL_RESPONSE_PIPE_MOUNT/$response_pipe" "$OTEL_TRACEPARENT" "$kind" "$name" + _otel_sdk_communicate "SPAN_START" "$response_pipe" "$OTEL_TRACEPARENT" "$kind" "$name" \cat "$response_pipe" \rm "$response_pipe" &> /dev/null } @@ -171,9 +172,9 @@ otel_span_attribute_typed() { otel_span_traceparent() { local span_handle="$1" - local response_pipe="$(\mktemp -u)_opentelemetry_shell_$$.pipe" + local response_pipe="$(\mktemp -u -p "$OTEL_SHELL_RESPONSE_PIPE_MOUNT")_opentelemetry_shell_$$.pipe" \mkfifo $_otel_mkfifo_flags "$response_pipe" - _otel_sdk_communicate "SPAN_TRACEPARENT" "$OTEL_SHELL_RESPONSE_PIPE_MOUNT/$response_pipe" "$span_handle" + _otel_sdk_communicate "SPAN_TRACEPARENT" "$response_pipe" "$span_handle" \cat "$response_pipe" \rm "$response_pipe" &> /dev/null } @@ -196,9 +197,9 @@ otel_span_deactivate() { otel_event_create() { local event_name="$1" - local response_pipe="$(\mktemp -u)_opentelemetry_shell_$$.pipe" + local response_pipe="$(\mktemp -u -p "$OTEL_SHELL_RESPONSE_PIPE_MOUNT")_opentelemetry_shell_$$.pipe" \mkfifo $_otel_mkfifo_flags "$response_pipe" - _otel_sdk_communicate "EVENT_CREATE" "$OTEL_SHELL_RESPONSE_PIPE_MOUNT/$response_pipe" "$event_name" + _otel_sdk_communicate "EVENT_CREATE" "$response_pipe" "$event_name" \cat "$response_pipe" \rm "$response_pipe" &> /dev/null } @@ -224,9 +225,9 @@ otel_event_add() { otel_metric_create() { local metric_name="$1" - local response_pipe="$(\mktemp -u)_opentelemetry_shell_$$.pipe" + local response_pipe="$(\mktemp -u -p "$OTEL_SHELL_RESPONSE_PIPE_MOUNT")_opentelemetry_shell_$$.pipe" \mkfifo $_otel_mkfifo_flags "$response_pipe" - _otel_sdk_communicate "METRIC_CREATE" "$OTEL_SHELL_RESPONSE_PIPE_MOUNT/$response_pipe" "$metric_name" + _otel_sdk_communicate "METRIC_CREATE" "$response_pipe" "$metric_name" \cat "$response_pipe" \rm "$response_pipe" &> /dev/null } diff --git a/tests/auto/test_auto_injection_docker.shell b/tests/auto/test_auto_injection_docker.shell index 3c94bd764..22e013c60 100755 --- a/tests/auto/test_auto_injection_docker.shell +++ b/tests/auto/test_auto_injection_docker.shell @@ -23,6 +23,10 @@ assert_equals "hello world 4" "$(sudo docker run --entrypoint echo debian:latest span="$(resolve_span '.name == "echo hello world 4"')" assert_equals "SpanKind.INTERNAL" "$(\echo "$span" | \jq -r '.kind')" +assert_equals "hello world 5" "$(sudo docker run --volume /tmp:/tmp debian:latest echo hello world 5)" +span="$(resolve_span '.name == "echo hello world 5"')" +assert_equals "SpanKind.INTERNAL" "$(\echo "$span" | \jq -r '.kind')" + sudo docker image ls assert_equals 0 "$?" @@ -38,8 +42,8 @@ assert_equals 0 "$?" # from https://github.com/actions/first-interaction/blob/main/Dockerfile (added because it was hanging forever) dockerfile="$(mktemp)" echo 'FROM node:20.10-buster-slim' >> "$dockerfile" -echo 'ENTRYPOINT ["node", "-e", "console.log(\"hello world 4\")"]' >> "$dockerfile" +echo 'ENTRYPOINT ["node", "-e", "console.log(\"hello world 6\")"]' >> "$dockerfile" sudo docker build -t docker_test_0 -f "$dockerfile" . assert_equals 0 "$?" -assert_equals "hello world 4" "$(sudo docker run --rm=true docker_test_0)" +assert_equals "hello world 6" "$(sudo docker run --rm=true docker_test_0)" assert_equals 0 "$?"