x-ray
Introduction
- Troubleshooting application performance and errors
- Distributed tracing of Micro-services
- Compatible with
- Lambda
- Beanstalk
- ECS
- ELB
- API Gateway
- EC2 instances or any on-premises app server
- You can enable x-ray by:
- Install the x-ray daemon (on a server) or enable x-ray integration (some AWS services such as lambda)
- You can instrument x-ray in your code using the AWS SDK
- python, java, go, .NET, node.js
X-Ray APIs
- Writes
- PutTraceSegments - Uploads a segment document int x-ray
- PutTelemetryRecords - Used by the AWS X-Ray daemon o upload telemetry
- GetSamplingRules - Retrieve all sampling rules
- Reads
- GetServiceGraph - main graph
- BatchGetTraces - Retries a list of traces specified by Id
- GetTraceSummaries - Retrieve Ids and annotations for traces available for a specified time frame using an optional filter
- GetTraceGraph
X-Ray with Beanstalk
- Beanstalk includes the x-ray daemon
- You can run the daemon by setting an option in the Elastic Beanstalk console or with a configuration file (in .ebextensions/xray-daemon.confi)
option_settings: aws:elasticbeanstalk:xray: XRayEnabled: true - Make sure to give your instance profile the correct IAM permissions so that the x-ray daemon can function correctly
- You app code must still be instrumented with the X-Ray integration code
ECS + X-Ray
- Pattens:
- Run the X-Ray daemon container on every EC2 instance
- Run the X-Ray container as a sidecar for the app containers (the only way to get ECS with Fargate working with X-Ray)