...
Once coverage monitoring has started, the code invokes and retrieves the original lambda's response.
Test Duration Requirement
Please note that tests must run for a minimum of 1s for SeaLights to calculate coverage. If your test duration is under 1s, adding a brief pause to your test will allow SeaLights to complete the coverage sampling process.
Step 6 - Terminating Coverage
...
Flag | Description | Type | Mandatory | Example |
---|---|---|---|---|
| Set the location of all lambda functions root dir | List of paths | Yes, at least one path is required | “./function_1,./function_2" |
| Set the address of the collector URL | a valid URL | No, but if not set by ENV Var the footprints will not be set | https://collector.host:16500 |
| Set the path of saving the sealights_layer | a valid dir | No, but if not set a sealights_layer will be saved"./"a sealights_layer will be saved | "./" |
Alternatively to exporting the layer, you can use the public layers in aws:arn:aws:lambda:eu-west-1:442677231940:layer:sl-python-layer:7
arn:aws:lambda:eu-west-2:442677231940:layer:sl-python-layer:7
arn:aws:lambda:us-east-1:442677231940:layer:sl-python-layer:7
arn:aws:lambda:us-west-2:442677231940:layer:sl-python-layer:7
sl_lambda_config.json
This json file contains the agent config parameter's that needed to be sent in each footprint.
...
Code Block |
---|
.... Resources: ### Adding Sealights Lambda Layer SealightsLayer: Type: AWS::Serverless::LayerVersion Properties: LayerName: sealights_layer Description: Layer for managing code coverage ContentUri: sealights_layer/ CompatibleRuntimes: - python3.11 ### End of Sealights Lambda Layer Function1: Type: AWS::Serverless::Function Properties: CodeUri: function_1/ Handler: app.lambda_handler Runtime: python3.11 ### Start of Ref to Sealights Layer Support Layers: - !Ref SealightsLayer Environment: Variables: AWS_LAMBDA_EXEC_WRAPPER: /opt/setupsealights-extension ### End of Ref to Sealights Layer Support Events: HelloWorld: Type: Api Properties: Path: /function1 Method: get ..... |
...
The Content Uri in Sealights Layer should be to related
--exportlayerpath
path on sl-python configlambda commandThe '
AWS_LAMBDA_EXEC_WRAPPER: /opt/setupsealights-extension
' is a mandatory env var to set in order to invoke Sealights Lambda handler
...
In addition to the mandatory 'AWS_LAMBDA_EXEC_WRAPPER: /opt/setupsealights-extension
' environment variable there are more environment variables that override the sl_lambda_config.json values:
...
Where the collector URL should set to the real collector url.
after running this command a file called sl_lambda_config.json
will be created.
Step 2 - Amending the deploy manifest
...
Code Block |
---|
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: sealigths-lambda-example-sl Globals: Function: Timeout: 30 Resources: SealightsLayer: Type: AWS::Serverless::LayerVersion Properties: LayerName: sealights_layer Description: Layer for managing code coverage ContentUri: sealights_layer/ CompatibleRuntimes: - python3.11 Function1: Type: AWS::Serverless::Function Properties: CodeUri: function_1/ Handler: app.lambda_handler Runtime: python3.11 Layers: - !Ref SealightsLayer Environment: Variables: AWS_LAMBDA_EXEC_WRAPPER: /opt/setupsealights-extension SL_DEBUG: true Events: HelloWorld: Type: Api Properties: Path: /function1 Method: get Function2: Type: AWS::Serverless::Function Properties: CodeUri: function_2/ Handler: app.lambda_handler Runtime: python3.11 Layers: - !Ref SealightsLayer Environment: Variables: AWS_LAMBDA_EXEC_WRAPPER: /opt/setupsealights-extension Events: HelloWorld: Type: Api Properties: Path: /function2 Method: get Outputs: Function1: Description: "Sealights Lambda Function1 ARN" Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/function1/" Function2: Description: "Sealights Lambda Function2 ARN" Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/function2/" |
...