Description
With Tracing: Active, Lambda sends X-Ray traces for sampled invocations of a SAM function.
Potential impact
Without tracing, locating a delay or failure across services can take longer.
Remediation
Enable active tracing on the function you need to investigate. Give an explicitly supplied execution role X-Ray write permissions. Instrument the function’s downstream calls if you need to trace them.
Examples
The revision adds Tracing: Active to an image-based function. Supply your image URI and its entry point, command, and working directory.
Before
yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
Function:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
ImageUri: account-id.dkr.ecr.region.amazonaws.com/ecr-repo-name:image-name
ImageConfig:
Command:
- app.lambda_handler
EntryPoint:
- entrypoint1
WorkingDirectory: workDir
Tags:
Type: AWS Serverless Function
After
yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
Function:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
ImageUri: account-id.dkr.ecr.region.amazonaws.com/ecr-repo-name:image-name
ImageConfig:
Command:
- app.lambda_handler
EntryPoint:
- entrypoint1
WorkingDirectory: workDir
Tags:
Type: AWS Serverless Function
Tracing: Active