[AWS] X-Ray

X-Ray traces applications and helps to identify potential problems or optimizations in the applications. It provides a visualization of your application’s underlying components.


Features

The X-Ray Service Map provides an end-to-end view of requests as they travel through your application. It allows you to troubleshoot the root cause of connection/performance issues and errors.

  • Segments
    • data about the work done by application
    • request, response, issues …
  • Subsegments
    • a more granular view of data inside of segments
  • Service Graph
    • a JSON document of how the application’s services and resources interact (visualized)
  • Traces
    • At first, HTTP header trace ID (X-Amzn-Trace-Id) -> and propagates downstream to track through the system

X-Ray can track application errors

  • Errors (Client error – 400)
  • Fault (Server error – 500)
  • Throttle (429 Too many requests)

X-Ray Architecture

  • The X-Ray agent must be installed on your EC2 instance.
  • Configure your applications using the X-Ray SDK
    • The X-Ray SDK gathers information from request and response headers, the code in your application, and metadata about the AWS resources on which it runs, and sends this trace data to X-Ray. e.g. incoming HTTP requests, error codes, latency data.

X-Ray Daemon

X-Ray Daemon is an AWS application that

  • listens on UDP port 2000
  • collects raw segment data
  • sends it to the AWS X-Ray API

X-Ray SDK code sends the data to the X-Ray daemon, which buffers segments in a queue and uploads them to the X-Ray service in batches.

  • Run the X-Ray deamon to a Dockerized application
    • Run the X-Ray daemon in a new Docker container alongside the other microservices which make up your application
  • Run the X-Ray deamon on AWS Elastic Beanstalk
    • Run the X-Ray daemon on Amazon EC2 instances inside your Elastic Beanstalk environment.

Integration

X-Ray integrates with AWS Services or custom applications.

  • AWS Services
    • EC2, Lambda, Elastic Beanstalk, SNS, SQS, DynamoDB, Elastic Load Balancer, Elastic Container Service, and API Gateway.
  • Custom Application
    • applications written in .NET, Java, Node.js, Go, Ruby, or Python.
  • The X-Ray SDK automatically captures metadata of API calls made to AWS services.

Annotations

  • Annotations are simple key-value pairs that indexed in the X-Ray.
  • Annotations are used to filter traces

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s