import{RestApi}from'@aws-cdk/aws-apigateway';exportclassMyStackextendscdk.Stack{constructor(scope:cdk.Construct,id:string,props?:cdk.StackProps){super(scope,id,props);constmyApi=newRestApi(scope,'MyApi',{// Enable tracing on API GatewaydeployOptions:{tracingEnabled:true,},});}}
1 2 3 4 5 6 7 8 91011121314
{"Resources":{"Api":{"Type":"AWS::Serverless::Api","Properties":{"DefinitionUri":"openapi.yaml","StageName":"prod",// Enable tracing on API Gateway"TracingEnabled":true}}}}
123456789
Resources:Api:Type:AWS::Serverless::ApiProperties:DefinitionUri:openapi.yamlStageName:prod# Enable tracing on API GatewayTracingEnabled:true
12345
provider:name:aws# Enable tracing on API Gatewaytracing:apiGateway:true
1 2 3 4 5 6 7 8 9101112131415161718192021222324
resource"aws_api_gateway_rest_api""this"{body=file("openapi.yaml")}resource"aws_api_gateway_deployment""this"{rest_api_id=aws_api_gateway_rest_api.this.idtriggers={redeployment=sha1(jsonencode(aws_api_gateway_rest_api.this.body))}lifecycle{create_before_destroy=true}}resource"aws_api_gateway_stage""this"{deployment_id=aws_api_gateway_deployment.this.idrest_api_id=aws_api_gateway_rest_api.this.idstage_name="prod" # Enable tracing on API Gatewayxray_tracing_enabled=true}
You might use third party solutions for monitoring serverless applications. If this is the case, enabling tracing for API Gateway might be optional. Refer to the documentation of your monitoring solutions to see if you should enable AWS X-Ray tracing or not.