DEV Community


Posted on

AWS X-Ray Cheat Sheet



  • Google Stackdriver
  • Azure Monitor
  • Elastic Observability
  • Datadog
  • Splunk


  • Trace request across microservices/AWS services
    • Analyze, Troubleshoot errors, Solve performance issues
    • Gather tracing information
    • From applications/components/AWS Services
    • Tools to view, filter and gain insights (Ex: Service Map)
  • How does Tracing work?
    • Unique trace ID assigned to every client request
    • X-Amzn-Trace-Id:Root=1-5759e988-bd862e3fe
    • Each service in request chain sends traces to X-Ray with trace ID
    • X-Ray gathers all the information and provides visualization
    • How do you reduce performance impact due to tracing?
    • Sampling - Only a sub set of requests are sampled (Configurable)
    • How can AWS Services and your applications send tracing info?
    • Step 1 : Update Application Code Using X-Ray SDK
    • Step 2: Use X-Ray agents (EASY to use in some services! Ex: AWS Lambda)

  • Segments and Sub-segments can include an annotations object containing one or more fields that X-Ray indexes for use with Filter Expressions. It is indexed. Use up to 50 annotations per trace.
  • Total sampled request per second = Reservoir size + ((incoming requests per second - reservoir size) * fixed rate)
  • Default sampling X-ray SDK first request each second and 5% of any additional requests
  • Tracing header can be added in http request header
  • Annotations vs Segments vs Subsegments vs metadata
  • X-ray daemon listens for traffic on UDP port 2000
  • X-ray SDK provides interceptors to add your code to trace incoming HTTP requests.
  • X-ray in EC2: You need the X-Ray daemon to be running on your EC2 instances in order to send data to X-Ray. User data script could be used to install the X-Ray daemon in EC2 instance.
  • X-ray in ECS: In Amazon ECS, create a Docker image that runs the X-Ray daemon, upload it to a Docker image repository, and then deploy it to your Amazon ECS cluster.
  • X-ray in elastic beanstalk: Enable the X-Ray daemon by including the xray-daemon.config configuration file in the .ebextensions directory of your source code
  • AWS X-Ray helps developers analyze and debug production, distributed applications, such as those built using a micro-service architecture.
  • A segment can break down the data about the work done into subsegments. Subsegments provide more granular timing information and details about - downstream calls that your application made to fulfill the original request.
  • Add annotations to subsegment document if you want to trace downstream calls.
  • Segments and subsegment can include a metadata object containing one or more fields with values of any type, including objects and arrays.
  • Tracing header is added in the HTTP request header. A tracing header (X-Amzn-Trace-ld) can originate from the X-Ray SDK, an AWS service, or the - client request.
  • Use the GetTraceSummaries API to get the list of trace IDs of the application and then retrieve the list of traces using BatchGetTraces API in - order to develop the custom debug tool

Top comments (0)