Soru

Zorluk: KolayInstrumenting Distributed Tracing with AWS X-Ray

A developer has enabled active tracing on an AWS Lambda function that uses the AWS SDK for Python (boto3) to write data to an Amazon DynamoDB table. Although the Lambda function's execution is traced, the downstream calls to DynamoDB are missing from the AWS X-Ray service map. Which action must the developer take to include the DynamoDB calls in the X-Ray trace?

  1. Instrument the AWS SDK by using the patch_all or patch function from the X-Ray SDK in the Lambda function code.Cevap
  2. B
    Increase the Lambda function's timeout configuration to allow the service execution context to persist longer.
  3. C
    Configure the API Gateway integration type to use Lambda Custom integration to pass raw request payloads.
  4. D
    Increase the Amazon SQS visibility timeout to prevent messages from returning to the queue during tracing.

Cevap

Instrument the AWS SDK by using the patch_all or patch function from the X-Ray SDK in the Lambda function code.
The correct answer is to instrument the AWS SDK by using the patch_all or patch function from the X-Ray SDK in the Lambda function code. While enabling active tracing on the Lambda function configuration creates the parent trace segment, the AWS SDK client inside the code must be instrumented using the X-Ray SDK so that outgoing API calls to services like DynamoDB are recorded as subsegments.

Adım Adım Çözüm

1
Analyze the tracing configuration.
Active tracing is enabled on the Lambda function, which creates the main segment, but downstream AWS SDK calls are not being intercepted.
By default, enabling active tracing on Lambda only traces the function's entry, initialization, and execution. Outgoing calls via the AWS SDK require explicit library instrumentation.
2
Identify the mechanism for SDK instrumentation.
The AWS SDK client needs to be wrapped or patched by the AWS X-Ray SDK.
Instrumenting the SDK allows the X-Ray library to automatically capture subsegments for downstream AWS API requests (like DynamoDB) and link them to the parent segment.
3
Select the correct SDK function.
In Python, the developer should use the patch or patch_all function from the X-Ray SDK.
Calling patch_all() dynamically patches supported libraries, including boto3, ensuring all outgoing calls to DynamoDB are traced.

Anahtar Kavram

AWS X-Ray SDK Instrumentation
Tahmini Süre:45s
Bu soruyu puanla