Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-89983: remove doc/ from lambda build; fix logging #152

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 /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 /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} will be preloaded." } if handler_file
xuan-cao-swi marked this conversation as resolved.
Show resolved Hide resolved

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