Deployment Integrations

Setting up Java SDK with AWS SAM

AWS SAM
AWS SAM

Step 1: Add Configuration Changes on the SAM template.yml

  • Add the thundra_apiKey environment variable along with your Thundra API key.

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

    Latest version of the Thundra Java layer:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraJavaLayerVersion:
Type: Number
Default: 29 # Or use any other version
Globals:
...
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-java-layer:${ThundraJavaLayerVersion}
  • Change the handler of functions to be wrapped to

    io.thundra.agent.lambda.core.handler.ThundraLambdaHandler

    Alternatively, if you want to wrap all of the functions in your SAM configuration file, you can set the handler in the Globals section.

Globals:
Function:
...
Handler: io.thundra.agent.lambda.core.handler.ThundraLambdaHandler
  • For each wrapped function, add the thundra_agent_lambda_handler environment variable with the full class-name (package and class name) of your function.

Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
thundra_agent_lambda_handler: com.mycompany.MyHandler

An example configuration:

Parameters:
ThundraAWSAccountNo:
Type: Number
Default: 269863060030
ThundraJavaLayerVersion:
Type: Number
Default: 29 # Or use any other version
Globals:
Function:
Runtime:
Timeout: 5
Handler: io.thundra.agent.lambda.core.handler.ThundraLambdaHandler
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-java-layer:${ThundraJavaLayerVersion}
Environment:
Variables:
thundra_apiKey: <your_api_key>
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
Environment:
Variables:
thundra_agent_lambda_handler: com.mycompany.MyHandler

Step 2: Test the Application

To build and run your functions locally:

sam build && sam local invoke

Step 3: Monitor Your Function with Thundra

After generating your first invocation, the “Next” button will appear in the Invocation Monitor bar. Simply click the button to see monitoring data from your invocation.