Voiced by Amazon Polly |
Introduction
AWS X-Ray is a service that gathers information about the requests that an application serves and offers tools for viewing, filtering, and gaining insights into that information to spot problems and chances for improvement.
It is a service that aids in the analysis and debugging of distributed applications for developers. Customers who employ cloud-hosted apps or applications running on their workstations for development use X-Ray to track application traces, including the effectiveness of calls to other downstream components or services.
Applications created in Node.js, Java, Go, C#.NET, and Python can be traced using AWS X-Ray.
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
End-to-End tracing
AWS X-Ray offers an end-to-end, cross-service perspective of requests made to an application. Combining the information obtained from application services into one object known as a trace provides an application-centric perspective of requests going through the application. To identify the specific service or application tier or tiers where problems are occurring, one can utilize this trace to track the journey of a single request.
Request Sampling
Applications that are in production or that are still being developed are the ideal candidates for setting the trace sampling rate. Requests are continuously tracked by X-Ray, which maintains a sample of them for analysis. This avoids the expense of maintaining and managing an excessive quantity of data volume while providing the right amount of data to make analysis meaningful.
AWS X-Ray SDK for Python
A collection of libraries that can be used to create and transmit traces to X-Ray using the X-Ray daemon.
Download the SDK with pip.
1 |
pip install aws-xray-sdk |
X-Ray daemon
The AWS X-Ray daemon is a piece of software that listens on UDP port 2000 by default for traffic, collects raw segment data, and sends it to the AWS X-Ray API. For data transmitted by the AWS X-Ray SDKs to reach the X-Ray service, the daemon needs to be running in conjunction with the SDKs. Segments created when a service receives an upstream request are forwarded by the X-Ray Daemon. The trace data is sent to the service by an external process that is run in an instance.
Steps to Install X-Ray daemon
Step 1 –
1 2 3 4 |
wget https://s3.dualstack.eu-west-1.amazonaws.com/aws-xray-assets.eu-west-1/xray-daemon/aws-xray-daemon-3.x.deb sudo dpkg -i aws-xray-daemon-3.x.deb sudo systemctl enable xray sudo systemctl status xray |
Step 2 – Create an IAM role called “AWSXRayDaemonWriteAccess” with write permissions and some read permissions to facilitate the use of sampling rules to deploy the application in AWS.
- The X-Ray SDK for Python creates a segment for each sampled request when you add the middleware to your application and specify a segment name. Timing, method, and HTTP request disposition are all included in this part. This segment’s subsegments are created by further instrumentation.
- To instrument incoming HTTP requests, the X-Ray SDK for Python supports middleware called a flask. Setting up a segment name on the xray recorder is the first step in instrumenting flask application. Then, modify the code of the Flask application using the XRayMiddleware function.
Step 3 – Add the following configuration to the main page of flask your application
1 2 3 4 5 6 |
from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.ext.flask.middleware import XRayMiddleware app = Flask(__name__) xray_recorder.configure(service='My application') // application name XRayMiddleware(app, xray_recorder) patch_all() // It will patch all the request to the application |
Step 4 – For dependency management add SDK in requirement.txt
- aws-xray-sdk==2.4.2
- run requirement.txt file using pip command ‘pip install -r requirements.txt’
- Run the python application app.py using the below command
- python3 app.py by sending the request to the application
- Send requests to your application for generating traces
- If the configurations are right then the X-Ray daemon will be sending the traces and logs can be checked using ‘tail -f /var/log/xray/xray.log’
Step 5 – After launching an application, can see the service map in the X-Ray console in AWS
Step 6 – Click on any node in the graph to view the traces behind it which is used to find traces by URL, response code, or other information from the summary of traces. This enables us to examine every action occurring within your applications.
Conclusion
Hence the service map in X-Ray depicts the connection between the services in an application as well as aggregated metrics for each service, such as average latency and failure rates. can perform call detections across availability zones or regions, build dependency trees, and more.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner, AWS Config, Amazon EMR and many more.
FAQs
1. How long does it require for an X-Ray to make trace data available?
ANS: – Usually, the service receives trace data supplied to X-Ray and makes it accessible for retrieval and filtering within 30 seconds of receiving it.
2. Which kinds of applications work with X-Ray?
ANS: – A web application’s HTTP requests or asynchronous events that use Amazon SQS queues can be traced using X-Ray.

WRITTEN BY Abhilasha D
Abhilasha D is a Research Associate-DevOps at CloudThat. She is focused on gaining knowledge of Cloud environment and DevOps tools. She has keen interest in learning and researching on emerging technologies.
Comments