From 52f4f5bc657f12b67a640e4ce1f5b713dc4adf4f Mon Sep 17 00:00:00 2001 From: Laplie Anderson Date: Mon, 15 Jul 2024 09:49:12 -0400 Subject: [PATCH] account for differences in host_inject and auto_inject --- .gitlab/prepare-oci-package.sh | 5 +++-- lib-injection/host_inject.rb | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitlab/prepare-oci-package.sh b/.gitlab/prepare-oci-package.sh index d542c2ca78b..611b2c867c9 100755 --- a/.gitlab/prepare-oci-package.sh +++ b/.gitlab/prepare-oci-package.sh @@ -5,11 +5,12 @@ set -e mkdir sources cp ../lib-injection/host_inject.rb sources -sed -i "s#/opt/datadog/apm/library/ruby/#/opt/datadog-packages/datadog-apm-library-ruby/$RUBY_PACKAGE_VERSION/#g" sources/host_inject.rb - # Kubernetes injection expects a different path cp sources/host_inject.rb source/auto_inject.rb +sed -i "s#PATH_PLACEHOLDER#/opt/datadog-packages/datadog-apm-library-ruby/${RUBY_PACKAGE_VERSION}#g" sources/host_inject.rb +sed -i "s#PATH_PLACEHOLDER#/datadog-lib#g" sources/auto_inject.rb + cp -r ../tmp/${ARCH}/* sources cp ../tmp/version.txt sources/version diff --git a/lib-injection/host_inject.rb b/lib-injection/host_inject.rb index 1f1b56a6837..7e516cb344a 100644 --- a/lib-injection/host_inject.rb +++ b/lib-injection/host_inject.rb @@ -26,8 +26,10 @@ def dd_skip_injection! def dd_send_telemetry(events) pid = Process.respond_to?(:pid) ? Process.pid : 0 # Not available on all platforms - tracer_version = if File.exist?('/opt/datadog/apm/library/ruby/version.txt') - File.read('/opt/datadog/apm/library/ruby/version.txt').chomp + tracer_version = if File.exist?('PATH_PLACEHOLDER/version.txt') + File.read('PATH_PLACEHOLDER/version.txt').chomp + elsif File.exist?('PATH_PLACEHOLDER/version') + File.read('PATH_PLACEHOLDER/version').chomp else 'unknown' end @@ -58,7 +60,7 @@ def dd_send_telemetry(events) major, minor, = RUBY_VERSION.split('.') ruby_api_version = "#{major}.#{minor}.0" - dd_lib_injection_path = "/opt/datadog/apm/library/ruby/#{ruby_api_version}" + dd_lib_injection_path = "PATH_PLACEHOLDER/#{ruby_api_version}" dd_debug_log "Loading from #{dd_lib_injection_path}..." supported_ruby_api_versions = ['2.7.0', '3.0.0', '3.1.0', '3.2.0'].freeze