Skip to content

Commit

Permalink
Merge pull request #152 from solarwinds/NH-89983
Browse files Browse the repository at this point in the history
NH-89983: remove doc/ from lambda build; fix logging
  • Loading branch information
xuan-cao-swi authored Sep 10, 2024
2 parents bc36931 + afe2cfd commit 72e1d58
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lambda/otel/Dockerfile_3_2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN export gem_file=$(cat gem_file.txt) && \
bundle update; \
fi

RUN rm /build/layer/ruby/ruby/3.2.0/cache/*
RUN rm /build/layer/ruby/ruby/3.2.0/cache/* && rm -rf /build/layer/ruby/ruby/3.2.0/doc/*

WORKDIR /build/layer/ruby/ruby
RUN zip -qr gems-3.2.0.zip 3.2.0/
Expand Down
2 changes: 1 addition & 1 deletion lambda/otel/Dockerfile_3_3
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN export gem_file=$(cat gem_file.txt) && \
bundle update; \
fi

RUN rm /build/layer/ruby/ruby/3.3.0/cache/*
RUN rm /build/layer/ruby/ruby/3.3.0/cache/* && rm -rf /build/layer/ruby/ruby/3.3.0/doc/*

WORKDIR /build/layer/ruby/ruby
RUN zip -qr gems-3.3.0.zip 3.3.0/
Expand Down
11 changes: 8 additions & 3 deletions lambda/otel/layer/otel_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def preload_function_dependencies

unless handler_file && File.exist?("#{default_task_location}/#{handler_file}.rb")
OpenTelemetry.logger.warn { 'Could not find the original handler file to preload libraries.' }
return
return nil
end

libraries = File.read("#{default_task_location}/#{handler_file}.rb")
Expand All @@ -27,11 +27,16 @@ def preload_function_dependencies
rescue StandardError => e
OpenTelemetry.logger.warn { "Could not load library #{lib}: #{e.message}" }
end
handler_file
end

unless ENV['SW_APM_LAMBDA_PRELOAD_DEPS'].to_s.downcase == 'false'
if ENV['SW_APM_LAMBDA_PRELOAD_DEPS'].to_s.downcase == 'false'
OpenTelemetry.logger.warn { "SW_APM_LAMBDA_PRELOAD_DEPS set to #{ENV.fetch('SW_APM_LAMBDA_PRELOAD_DEPS', nil)}. No libraries will be preloaded." }
preload_function_dependencies
else

handler_file = preload_function_dependencies

OpenTelemetry.logger.info { "Libraries in #{handler_file} have been preloaded." } if handler_file

require 'opentelemetry-registry'
require 'opentelemetry-instrumentation-all'
Expand Down

0 comments on commit 72e1d58

Please sign in to comment.