> For the complete documentation index, see [llms.txt](https://mamawhocode.gitbook.io/aws/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mamawhocode.gitbook.io/aws/services/devtools/x-ray.md).

# X-Ray

Analyze and debug your applications

[Docs](https://docs.aws.amazon.com/xray/?icmpid=docs_homepage_devtools) | [X-Ray console](https://docs.aws.amazon.com/xray/latest/devguide/xray-console.html) | [Integrating with other services](https://docs.aws.amazon.com/xray/latest/devguide/xray-services.html) |

## Overview

* A service that *<mark style="color:red;">collects data</mark>* about requests that your application serves, and *<mark style="color:red;">provides tools</mark>* that you can use to view, filter, and gain insights into that data to <mark style="background-color:yellow;">identify issues</mark> and <mark style="background-color:yellow;">opportunities for optimization</mark>.
* X-Ray creates a map of services used by your application with trace data. You can use the trace data to drill into specific services or issues. This data provides a view of connections between services in your application and aggregated data for each service, including average latency and failure rates.

## Features

### Environment variables

* `AWS_XRAY_CONTEXT_MISSING`: X-ray SDK use this to determine behavior if your function try to record X-RAY data. Lambda set this to `LOG_ERROR` by default.
* *`X_AMZN_TRACE_ID`:* used by Lambda to communicate with X-Ray.

### Annotation for segment/subsegment

Segments and subsegments can include an annotations object containing one or more fields that X-Ray indexes for use with *<mark style="color:red;">**filter expressions**</mark>*.

## Concepts

* [*Active instrumentation*](https://docs.aws.amazon.com/xray/latest/devguide/xray-services.html)*:* is like adding special code to your app that reports back every time something important happens, like a user logging in or a page loading.
* [*Passive instrumentation*](https://docs.aws.amazon.com/xray/latest/devguide/xray-services.html)*: like putting a camera* to watch what's happening in your app without actively changing or adding anything to it.
* [X-ray deamon:](#concepts) is *an agent* acts as a proxy between application being traced and X-Ray.

  <figure><img src="https://2259236002-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fuh9xZDZ53qGqmMCM44PU%2Fuploads%2FvQ3IKjQuSg1HjZaeWG2I%2Fimage.png?alt=media&amp;token=dfa1429f-dd15-4a0a-a9b9-fbdd62b61131" alt=""><figcaption><p>enable x-ray deamon</p></figcaption></figure>
* [*Segment*](#concepts): app you are tracing send data to X-Ray in a form of segment. A Segment is a JSON document, contains infor about the requests.
* ***Subsegment***: segment can breakdown to subsegment. Subsegments provide more granular timing information and <mark style="color:red;">details</mark> about downstream calls that your application made to fulfill the original request. A subsegment can contain *<mark style="color:red;">additional details</mark>* about a call to an AWS service, an external HTTP API, or an SQL database.
* [Trace](#concepts): segment are grouped together call a trace.
* [*Trace map*](/aws/services/devtools/x-ray.md): provides an `end-to-end` view of requests as they travel through your application services. Integrates `Application Signals` from CloudWatch to discover and monitor application services and dependencies across AWS services.
* Trace call:
* [Group](#concepts): a collection of traces that are defined by a filter expression. Groups are identified by their name or an ARN and contain a filter expression.
