Explore X-Ray

X-Ray setup

Take a look at the setup architecture on EC2 and on container environments such as ECS/EKS. X-Ray has an agent that runs as a separate process from your application. The X-Ray SDK collects traces from the application and sends them to the local agent over UDP. The agent then sends the traces to the X-Ray service using X-Ray APIs.

X-Ray setup

Service map on X-Ray

Go to AWS X-Ray Service map page You should be able to see a service map as shown below.

The Service map shows all the microservices and other components the application is making use of. When None is selected at the bottom right, you will be able to see the average response times and requests served by each service.

Switch to Traffic and Health modes to see the size of the circles (nodes) adjusting to the reflect traffic and health status relative to other services in the application.

Trace Duration

You can view upto 6 hours of trace data at any given point. Select the duration from the control at the top right as shown below. Duration

If you’re not aware of basic X-Ray concepts, it would help to spend a few minutes to get clarity on Segments, Subsegments, Traces and more here before proceeding further.

View Traces

  • Clicking on a Node will show you a side bar which has a response time distribution graph for the requests that the node has processed. Look at the screenshot below that shows the S3 node being selected. It also indicates that there has been errors recorded as well.


  • To see traces between any 2 services, just click on the arrow that connects the nodes. This will show the requests that are being processed between those 2 services in question.


  • You can click on View traces to see all traces that are captured between these 2 services. If you are interested in only seeing traces that have higher response time greater than 3 seconds, you can filter those traces only by simply selecting that area of the graph with the mouse.


  • You should see the screen such as the one below when you click on View traces. Clicking on a specific URL you’re interested will filter the traces for that URL and display them in the bottom table. Duration
  • Clicking on a Trace will show you a screen similar to the one below. Notice the Trace Map that shows the services that particular request traversed through. Below the Trace Map is the Segment timeline which shows the different Segments and Subsegments the trace contains.


  • Notice the subsegments that have error responses have an amber alert icon. Clicking on the alert will take you to the exceptions tab and show you the captured exception details.


X-Ray Annotations

  • Now go back to the Service map. Select the PayForAdoption node and click View traces. Click the URL that ends with /Payment/MakePayment and select any one of the traces. Click on Call Payment API as shown in the screenshot below.


  • This will show you Subsegment details, and on Annotations tab, you will be able to see the custom Annotations that were instrumented through the XRay SDK. You can see PetId and PetType being annotated in the trace.

Annotations are indexed and can be used to filter traces. For example, a Filter expression like annotation.PetType="puppy" will show me only the traces that have the annotations with PetType=puppy.


  • Now switch the Metadata tab to see the metadata information that was added to the trace Annotations

XRay can also show details about the AWS service being used in the trace. For example, select DynamoDB under Invocation subsegment. Go to the Resources tab and check details such as the table name, operation that was performed on the table etc. Go ahead and check this out for other services as well to see service specific information.