This guide outlines detailed steps for setting up a test environment to evaluate both Lambda instrumentation (PR) and the Lambda layer (PR) for OpenTelemetry.
- Clone the repository using the
ruby-layer-wrapper
branch from this location. This branch contains the wrapper file absent in the original PR. - Navigate to
ruby/src/
and executesam build -u -t template.yml
. This action generates the.aws-sam
folder. Finally, run the script./zip_ruby_layer.sh -n <your_layer_name>
to create the zip file suitable for upload to AWS Lambda via the AWS console. - If using a different tracing platform, ensure its installation before creating the layers.
- The gems listed in
ruby/layer/Gemfile
are the ones to be installed and uploaded. - For custom OpenTelemetry initialization (e.g., requiring other vendor-modified agents), edit the
ruby/src/wrapper.rb
file accordingly.
Refer to: AWS Lambda Packaging Guide
- Create a new layer and upload the previously generated zip file.
- Associate this layer with a function by attaching it to the function configuration.
Assuming the lambda function is triggered (learn more about invoking functions) with the AWS_LAMBDA_URL
and AWS_LAMBDA_KEY
set:
Example of these two environment variables AWS_LAMBDA_URL=https://abcdefg.execute-api.location-1.amazonaws.com/default/your_lambda_function_name AWS_LAMBDA_KEY=0yN7bRPfu9g***********************0yvXsO7bRtpfu
Example Sinatra app code:
get '/call-with-lambda-aws' do
url = URI.parse(ENV['AWS_LAMBDA_URL'])
req = Net::HTTP::Get.new(url.to_s)
req['x-api-key'] = "#{ENV['AWS_LAMBDA_KEY']}"
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.scheme == 'https')
res = http.request(req)
content_type :json
{ :Output => "lambda: #{res.body}\n"}.to_json
end
Upon execution, expect to observe a single span with the span scope name as OpenTelemetry::Instrumentation::AwsLambda
, accompanied by comprehensive details.