Thundra APM
Search…
Deployment Integrations
Setting up Java SDK with AWS SAM
AWS SAM

Step 1: Add Thundra API Key

Add the THUNDRA_APIKEY environment variable along with your Thundra API key in the template.yml.
template.yml
1
Globals:
2
Function:
3
...
4
Environment:
5
Variables:
6
THUNDRA_APIKEY: <YOUR THUNDRA API KEY>
Copied!

Step 2: Add Thundra Layer

Add the Thundra layer to “Layers” in the Globals section in the template.yml. The ThundraAWSAccountNo and ThundraJavaLayerVersion parameters are defined under the Parameters section in the following configuration:
Latest version of the Thundra Java layer:
1
Parameters:
2
ThundraAWSAccountNo:
3
Type: Number
4
Default: 269863060030
5
6
ThundraJavaLayerVersion:
7
Type: Number
8
Default: 65 # Or use any other version
9
10
Globals:
11
...
12
Layers:
13
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-java-layer:${ThundraJavaLayerVersion}
14
15
...
16
Copied!

Step 3: Switch Handler

Change the Handler of functions to be wrapped to io.thundra.agent.lambda.core.handler.ThundraLambdaHandler.
  • If you want to wrap all of the functions in your SAM configuration file, you can set the Handler in the Globals section.
1
Globals:
2
Function:
3
...
4
5
Handler: io.thundra.agent.lambda.core.handler.ThundraLambdaHandler
6
Copied!
Then, for each wrapped function, add the THUNDRA_AGENT_LAMBDA_HANDLER environment variable with the full class-name (package and class name) of your function's original handler.
1
Resources:
2
MyFunction:
3
Type: AWS::Serverless::Function
4
Properties:
5
Environment:
6
Variables:
7
THUNDRA_AGENT_LAMBDA_HANDLER: com.mycompany.MyHandler
8
Copied!
An example configuration:
1
Parameters:
2
ThundraAWSAccountNo:
3
Type: Number
4
Default: 269863060030
5
6
ThundraJavaLayerVersion:
7
Type: Number
8
Default: 65 # Or use any other version
9
10
Globals:
11
Function:
12
Runtime: java8
13
Timeout: 30
14
Handler: io.thundra.agent.lambda.core.handler.ThundraLambdaHandler
15
Layers:
16
- !Sub arn:aws:lambda:${AWS::Region}:${ThundraAWSAccountNo}:layer:thundra-lambda-java-layer:${ThundraJavaLayerVersion}
17
Environment:
18
Variables:
19
THUNDRA_APIKEY: <YOUR THUNDRA API KEY>
20
21
Resources:
22
MyFunction:
23
Type: AWS::Serverless::Function
24
Properties:
25
Environment:
26
Variables:
27
THUNDRA_AGENT_LAMBDA_HANDLER: com.mycompany.MyHandler
28
Copied!
Copy link