AWS Lambda Native Tracing for Ruby
This page covers the Ruby specifics for AWS Lambda tracing.
Supported Runtimes
ruby2.7
Installation
As of version 1.198.0
the in-process Ruby library detects and reports the information to Instanta automatically. Ensure that the library is present in your Gemfile and required
before your handler function.
Configuration
In order to send collected traces an AWS Lambda function needs to be provided with two environment variables:
INSTANA_ENDPOINT_URL
set to the URL of your Instana backend endpointINSTANA_AGENT_KEY
containing your Agent key
To provide these values to the handler in AWS Console UI go to the Lambda configuration page:
- Click on your Lambda function box
- In within the "Environment Variables" section click "Edit" and add two new variables
There are few optional environment variables that allow changing in-process sensor defaults, such as the list of HTTP headers to collect or a custom service name to use.
Instrumenting a handler function
To instrument your Ruby lambda function, wrap the functional code in a Instana.serverless.wrap_aws
block, passing the event and context as arguments. An example has been provided as follows:
require 'bundler/setup'
require 'json'
require 'instana'
def lambda_handler(event:, context:)
Instana.serverless.wrap_aws(event, context) do
{
statusCode: 200,
body: {
message: "Hello World!",
}.to_json
}
end
end