All the Python based lambda functions invoked by StepFunctions
(ReadDynamoDB, PriceLessThan55, PriceGreatThan55) in the application use AWS Distro for Open Telemetry (ADOT) to collect traces and send them to AWS X-Ray. Read the documentation for additional details on this topic.
The AWS Distro for OpenTelemetry Lambda (ADOT Lambda) layer for AWS Lambda provides a plug and play user experience by automatically instrumenting a Lambda function, by packaging OpenTelemetry Python together with an out-of-the-box configuration for AWS Lambda and AWS X-Ray.
Tracing using ADOT can be done by simply following these 3 simple steps:
AWS_LAMBDA_EXEC_WRAPPER = /opt/python/adot-instrumentto your Lambda function.
Active Tracingin your Lambda function
./pet_stack/cdk/lib/services/stepfn.ts and see the CDK Typescript code below. A new Lambda layer gets added created as show below:
In the following function the ADOT Layer is being added and the environment variable is also added which enables tracing through ADOT.
As a result, the traces from these lambda functions are being captured in X-Ray as shown in the screenshot below.