A developer has a serverless application where an Amazon API Gateway REST API integrates with an AWS Lambda function. The Lambda function processes incoming HTTP requests, sends messages to an Amazon SQS queue, and writes records to an Amazon DynamoDB table. Active tracing is enabled on both the API Gateway stage and the Lambda function. However, in the AWS X-Ray service map, downstream calls to SQS and DynamoDB are missing, and some messages in the SQS queue are being processed multiple times by downstream consumers. Which of the following actions should the developer take to ensure that downstream DynamoDB and SQS calls are properly traced in AWS X-Ray?
- Instrument the AWS SDK client using the AWS X-Ray SDK in the Lambda function code to capture downstream calls.Cevap
- BIncrease the tracing sampling rate in the API Gateway stage settings and rely on the active tracing enablement on the Lambda function to automatically trace downstream SDK calls.
- CConfigure the SQS queue's visibility timeout to be shorter than the Lambda function's timeout to ensure that trace context propagation is completed before the message is deleted.
- DHardcode the IAM User access key and secret key in the AWS SDK client configuration within the Lambda function code to authorize X-Ray trace context propagation.
Cevap
Instrument the AWS SDK client using the AWS X-Ray SDK in the Lambda function code to capture downstream calls.
The correct answer is to instrument the AWS SDK client using the AWS X-Ray SDK in the Lambda function code. Active tracing on AWS Lambda only traces the incoming invocation and function overhead. To trace downstream calls made to services like SQS or DynamoDB, the developer must explicitly wrap or patch the AWS SDK client using the AWS X-Ray SDK.
Adım Adım Çözüm
Anahtar Kavram
AWS X-Ray SDK instrumentation of AWS SDK clients is required to trace downstream calls from AWS Lambda.
Tahmini Süre:1m 30s