API Gateway X-Ray tracing disabled

Configure X-Ray to meet the REST API’s distributed-tracing needs.

Description

An API Gateway REST API stage can start X-Ray traces for sampled requests.

Potential impact

With passive tracing, diagnosing a slow request depends on an upstream service starting the trace.

Remediation

Set TracingEnabled: true on AWS::ApiGateway::Stage. Check for a sampled trace from the deployed stage. To follow requests into the backend, check tracing there too.

Examples

ProdStage refers to the REST API MyRestApi and its deployment MyDeployment. Define both in your template.

Before

yaml
Resources:
  ProdStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      StageName: Prod
      RestApiId: !Ref MyRestApi
      DeploymentId: !Ref MyDeployment
      TracingEnabled: false

After

yaml
Resources:
  ProdStage:
    Type: AWS::ApiGateway::Stage
    Properties:
      StageName: Prod
      RestApiId: !Ref MyRestApi
      DeploymentId: !Ref MyDeployment
      TracingEnabled: true

References