Integration Options

Using Layers
Without Layers
Serverless Framework
AWS SAM

Using Layers

Step 1: Deploy your function to AWS Lambda Bundle all your Python module files, along with any additional required Python libraries and upload it to the AWS Lambda console using the 'Upload a.zip file' option for the code entry type option. Note that Thundra dependencies are not expected to be in the artifact to be uploaded as it comes with layer that will be mentioned at later steps.

Step 2: Configure your function

  • Add api key to the environment variables on Amazon Lambda Console

  • Add thundra layer

    Click on the Layers option on your Lambda function console in the Designer tab. Then select Add Layer button and add Thundra Layer's ARN.

arn:aws:lambda:${region}:269863060030:layer:thundra-lambda-python-layer:${latest-version}
Latest layer version of thundra python layer

Note that the region part of the ARN is dynamic, so you need to change it according to the region where you deploy your function. So let say that you deploy your Lambda function to Oregon (us-west-2) region, and the layer version is 12. The layer ARN will be:arn:aws:lambda:us-west-2:269863060030:layer:thundra-lambda-python-layer:12

  • Configure handler

    Set handler to thundra.handler.wrapper . Set thundra_agent_lambda_handler environment variable value to to your handler.

Step 3: Invoke your deployed function by clicking on the Test button on the top right

Clicking on the 'Test' button on the top right of the AWS console will result in an invocation of your function after you have configured test data as per the specifications of your function.

Step 4: Monitor your function with Thundra Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.

Without Layers

Step 1: Install Thundra’s python package On the project directory run following command:

pip3 install thundra -t .

Step 2: Deploy your function to AWS Lambda Bundle all your Python module files, along with any additional required Python libraries and upload it to the AWS Lambda console using the 'Upload a.zip file' option for the code entry type option.

Step 3: Configure your function

  • Add api key to the environment variables on Amazon Lambda Console

  • Configure handler

    Set handler to thundra.handler.wrapper . Set thundra_agent_lambda_handler environment variable value to to your handler.

Step 4: Invoke your deployed function by clicking on the Test button on the top right

Clicking on the 'Test' button on the top right of the AWS console will result in an invocation of your function after you have configured test data as per the specifications of your function.

Step 5: Monitor your function with Thundra Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.

Serverless Framework

Step 1: Install Thundra’s serverless plugin to automatically wrap your functions

npm install serverless-plugin-thundra

Step 2: Adding Thundra's Serverless Plugin in serverless.yml File After installing Thundra’s serverless plugin, please specify it as a plugin for your serverless environment by adding it under the plugins section of your serverless.yml file.

serverless.yml
plugins:
- serverless-plugin-thundra

Step 3: Add thundra component to custom

Add the thundra component under custom with apiKey under that, as seen below:

serverless.yml
custom:
thundra:
apiKey: <YOUR THUNDRA API KEY>

Step 4: Add thundra_apiKey to environment variables under provider section in serverless.yml

serverless.yml
provider:
environment:
thundra_apiKey: <YOUR THUNDRA API KEY>

Step 5: Deploy & Test app

serverless deploy
serverless invoke --function functionName

Step 6: Monitor your function with Thundra

Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.

AWS SAM

Step 1: Add configuration changes on SAM template.yml

  • Add thundra_apiKey environment variable with your thundra api key.

Globals:
Function:
...
Environment:
Variables:
thundra_apiKey: <your_api_key>
  • Add the Thundra layer to Layers in globals section. ThundraAWSAccountNo and ThundraPythonLayerVersion parameters are defined under the Parameters section in the following configuration:

Latest layer version of thundra python layer:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraPythonLayerVersion:
Type: Number
Default: 12 # Or use any other version
Globals:
...
Function:
...
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-python-layer:${ThundraPythonLayerVersion}
  • Change Handler of functions to be wrapped to thundra.handler.wrapper or set Handler in the Globals section if you want to wrap all of the functions in your SAM configuration file.

Globals:
Function:
...
Handler: thundra.handler.wrapper
  • For each function that is wrapped, add thundra_agent_lambda_handler environment variable with handler path of your function.

Resources:
HelloWorldFunction1:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
thundra_agent_lambda_handler: hello_world_1.app.lambda_handler

An example configuration:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraPythonLayerVersion:
Type: Number
Default: 11 # Or use any other version
Globals:
Function:
Runtime: python3.7
Timeout: 5
Handler: thundra.handler.wrapper
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-python-layer:${ThundraPythonLayerVersion}
Environment:
Variables:
thundra_apiKey: <your_api_key>
Resources:
HelloWorldFunction1:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
thundra_agent_lambda_handler: hello_world_1.app.lambda_handler

Step 2: Test application

To build & run your functions locally:

sam build && sam local invoke

Step 3: Monitor your function with Thundra

Upon your first invocation ever, the Next button shall appear in the Invocation Monitor bar below and clicking it shall allow you to see monitoring data from your invocation.