---
title: AWS X-Ray
description: >-
  AWS X-Ray lets developers trace distributed applications built using AWS
  products
breadcrumbs: Docs > Integrations > AWS X-Ray
---

# AWS X-Ray

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com



{% alert level="warning" %}
The Datadog AWS Lambda X-Ray integration is only supported on commercial AWS accounts. Without a commercial Lambda account, the Datadog AWS Lambda X-Ray integration is not supported on the Datadog for Government site.
{% /alert %}


{% /callout %}

## Overview{% #overview %}

AWS X-Ray lets developers trace distributed applications built using AWS products. This integration provides traces for Lambda functions in the [Serverless](http://app.datadoghq.com/functions) function detail page. For more information, see [Serverless monitoring](https://docs.datadoghq.com/serverless/).

## Setup{% #setup %}

### Installation{% #installation %}

First, [enable the AWS integration](https://docs.datadoghq.com/integrations/amazon_web_services/) and ensure the following permissions are present in the policy document of your Datadog integration role:

```text
xray:BatchGetTraces,
xray:GetTraceSummaries
```

The `GetTraceSummaries` permission is used to get the list of recent traces. `BatchGetTraces` actually returns the full traces themselves.

Then, [enable the X-Ray integration](https://app.datadoghq.com/integrations/amazon-xray) within Datadog.

If you are using a [AWS KMS key](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html) to encrypt traces, add the `kms:Decrypt` method to your policy where the Resource is the KMS key used for X-Ray.

**Note:** Enabling the AWS X-Ray integration increases the amount of Indexed Spans which can impact your bill.

### Enabling AWS X-Ray for your functions{% #enabling-aws-x-ray-for-your-functions %}

1. Follow instructions from AWS to enable X-Ray tracing on your [Lambda functions](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html) and [API Gateways](https://docs.aws.amazon.com/xray/latest/devguide/xray-services-apigateway.html).
1. To get the most out of the AWS X-Ray integration, also [install the X-Ray SDK](https://docs.aws.amazon.com/xray/latest/devguide/xray-instrumenting-your-app.html#xray-instrumenting-xray-sdk) in your Lambda function.

### Enrich X-Ray traces with Datadog{% #enrich-x-ray-traces-with-datadog %}

Datadog can enrich X-Ray traces with spans and metadata generated by the Datadog APM client, and [merge](https://docs.datadoghq.com/serverless/distributed_tracing/serverless_trace_merging) them into a single Datadog trace for the same Lambda invocation.

1. [Install Datadog serverless monitoring](https://docs.datadoghq.com/serverless/installation) on your Lambda functions.
1. Set the environment variable `DD_MERGE_XRAY_TRACES` to `true` on your Lambda functions.

**Note**: You can only merge X-Ray traces with Lambda functions that are instrumented with Datadog.

## Data Collected{% #data-collected %}

The AWS X-Ray integration pulls in trace data from AWS, and does not collect any metrics or logs.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).
