Amazon X-Ray


Segments: Used to break down the data in sub segments.

Sub Segments: Provides, timings, other aws service/resource calls in downstream forms.

Inferred Segment: Allow display timings and calls to all services, even the services who does not support x-ray or tracing

annotations and metadata do not trace the calls of other aws services and resources. Instead these annotations and metadata are included in the segments and sub-segments.

sub-segments fields,

annotations can be used to filter the traced data from console. Also can trace by groups.

metadata can include some additional key value data, that can be helpful during the debugging and tracing.

X Ray Daemon

X-Ray sdk does not send data directly to X-Ray. Instead it sends data for multiple request in the daemon and then sends these to the X-Ray service.

X-Ray Daemon listens to traffic to UDP 2000 port,

Elastic Beanstalk Integration

X-Ray is already installed in the elastic beanstalk. To enable the x-ray, update/create a config under the beanstalk extensions, .ebextensions/x-ray-daemon.config. This can also be done using by management console.

To get trace data, code must instrumented withe x-ray sdk

ECS Integration

ECS can integrate x-ray by x-ray daemon and side-car pattern

  1. As Daemon Pattern: To use x-ray in ecs, we need to use the x-ray daemon container for each of the ecs instances. In this case, the x-ray daemon acts as the x-ray agents.
  2. As Side Car Pattern: In this case, each of the container in the ecs will have x-ray daemon inside it.

When we need to use x-ray in the fargate, we have to use the side-car pattern. Because, we do not have control over the ec2 instances in fargate.

To set up

Lambda Integration

To implement the X-ray tracing, we need to implement the followings,

EC2 Integration

To use x-ray we need the x-ray daemon in the ec2 instance. We can install this manually or update the user script to install the daemon.

Also we have to make sure the sg allow UDP of port 2000 for the x-ray daemon


After X-Ray collects the data, it use to combine abd summarize the trace data.

To make a custom debug tool,