The samples in this repository demonstrate different ways to integrate AWS X-Ray within a serverless application.
- xray: Simple tracing without code instrumentation.
- xray-instrumented: AWS X-Ray tracing with code instrumentation.
- xray-instrumented-layers: AWS X-Ray tracing with code instrumentation where the X-Ray Python SDK is provided by a Lambda Layer.
- xray-no-lambda: AWS X-Ray tracing for an API Gateway without a Lambda function.
- boilerplate: Contains a template for a SAM project with X-Ray tracing enabled.
The pipeline folder contains an AWS CloudFormation template for a pipeline using AWS CodeCommit, AWS CodePipeline and AWS CodeBuild.
The helpers folder contains script to help deploy Serverless applications locally and run calls against API Gateway.
To deploy any sample, go to the sample folder and run the following commands:
export S3_BUCKET="<your artifact bucket>"
make
To send test traffic for a particular sample, run this command in the sample folder:
make calls
By default, this will send 10 PUT requests and 500 GET requests.
After sending test traffic, you can check traces and the service map in the AWS Console.
To tear down resources, run this command in the sample folder:
make delete
You can deploy and make calls to all samples at once using the following commands from the root of this repository:
export S3_BUCKET="<your artifact bucket>"
# Deploy all samples
./helpers/deploy_all.sh
# Send requests to all samples
./helpers/calls_all.sh
Once you are done experimenting, you can delete all resources with the following command:
./helpers/delete_all.sh
To deploy all samples in CI/CD pipelines, run the following commands from the root of this repository:
export S3_BUCKET="<your artifact bucket>"
# Deploy all samples
./helpers/deploy_all_pipeline.sh
# Send requests to all samples
./helpers/calls_all_pipeline.sh
Once you are done experimenting, you can delete all resources with the following command:
./helpers/delete_all_pipeline.sh
The samples require these programs to be installed on your computer:
You would also need to install the cfn_flip package for Python3. You can install it with Pip by running python3 -m pip install cfn_flip
.
The get program triggers 500 HTTP calls by default, which can exceed the default limit of open file descriptors. You can increase this limit by running ulimit -n 4096
, which should be enough for the default case.
To learn more about this, check the ulimit help by typing help ulimit
or the man page for limits.conf
.
This sample code is made available under the MIT-0 license. See the LICENSE file.