Intro
- Provides tracing of requests as they travel through different AWS services to
- identify performance bottlenecks
- pinpoint errors
- understand dependencies in micro-services
- Useful for micro-services (distributed) applications where debugging is hard
- Ability to trace every request or a sample of requests
- Compatible with
- Lambda
- Elastic Beanstalk
- ECS
- ELB
- API Gateway
- EC2 instances or on-premise servers
- Security
- IAM for authorization
- KMS for encryption at rest
- Ability to send traces across accounts (allows to have a central account for application tracing)
Enabling X-Ray
- Use the AWS X-Ray SDK in your code (little code modification)
- Install X-Ray daemon if your application is running on EC2 or on-premise server. For other services, enable X-Ray integration (X-Ray daemon is already running).
- Configure IAM permissions for the X-Ray daemon or AWS service to write data to X-Ray.
How traces are sent
- X-Ray SDK captures calls to AWS services as well as other HTTP / HTTPS / Database / Queue calls.
- X-Ray SDK sends traces to X-Ray daemon through UDP on port 2000 (configure port mappings and network settings in the task definition file to allow the application to communicate with the X-Ray daemon container)
- X-Ray daemon batches the traces and sends them to X-Ray service every second.
X-Ray instrumentation in code
- Only configuration change is required in the code
- Can modify the application code to customize and annotate the traces sent by X-Ray SDK.
Terminologies
- Segments: data sent by each application / service
- Subsegments: provide more granular timing information and details about downstream calls (to AWS services, HTTP API or an SQL DB) that your application makes to fulfill the original request.
- Trace: segments collected together to form an end-to-end trace
- Annotations: indexed key-value pairs attached to traces for search capability and filtering traces using filter expressions
- Metadata: non-indexed key-value pairs attached to traces