Question

Difficulty: EasyInstrumenting Distributed Tracing with AWS X-Ray

A developer has enabled active tracing on an AWS Lambda function. The function calls an external web service using a standard HTTP client library. In the AWS X-Ray console, the trace map displays the Lambda function execution segment, but the downstream HTTP calls to the external web service are missing from the trace. What should the developer do to include the downstream HTTP calls in the X-Ray trace map?

  1. Instrument the HTTP client library inside the application code using the AWS X-Ray SDK.Answer
  2. B
    Enable Active Tracing on the Lambda function, which automatically instruments all downstream HTTP calls without requiring code modifications.
  3. C
    Configure the HTTP client to include hardcoded AWS IAM credentials with X-Ray write permissions in the request headers.
  4. D
    Increase the Lambda function's timeout configuration so that the execution environment has enough time to flush the trace data to X-Ray.

Answer

Instrument the HTTP client library inside the application code using the AWS X-Ray SDK.
To trace downstream HTTP calls, the developer must instrument the HTTP client library using the AWS X-Ray SDK. This instrumentation dynamically injects the X-Ray tracing header into outbound requests, allowing downstream services to participate in the trace.

Step-by-Step Solution

1
Identify why the downstream trace segment is missing.
Downstream HTTP client is not patched or instrumented, so the required tracing header (X-Amzn-Trace-Id) is not propagated.
AWS X-Ray active tracing on Lambda only covers Lambda itself; downstream calls require code instrumentation.
2
Apply the appropriate instrumentation method in the application code.
Use the AWS X-Ray SDK's HTTP instrumentation wrappers to wrap the HTTP client library.
This automatically injects the tracing header into outgoing HTTP requests and creates subsegments for the calls.

Key Concept

AWS X-Ray Downstream Context Propagation and HTTP Client Instrumentation
Estimated Time:45s
Rate this question