AWS Certified DevOps Engineer – ProfessionalMonitoring and LoggingMedium

A company is migrating a critical application to AWS Lambda functions and Amazon API Gateway. They need to implement distributed tracing to monitor the performance of individual Lambda invocations and their interactions with downstream services, such as Amazon DynamoDB and external APIs. The solution should provide a visual service map and detailed trace data to identify latency bottlenecks. The developers want to minimize manual instrumentation. Which approach should be used?

  1. AEnable CloudWatch Logs for Lambda and API Gateway, and use CloudWatch Logs Insights to analyze invocation durations.
  2. BConfigure API Gateway to enable X-Ray tracing and enable active tracing for Lambda functions.
  3. CInstrument each Lambda function with custom code to send trace data to an external OpenTelemetry collector.
  4. DDeploy custom metrics to CloudWatch using the Embedded Metric Format (EMF) for each Lambda function and DynamoDB table.
Show answer & explanation

Correct answer: B. Configure API Gateway to enable X-Ray tracing and enable active tracing for Lambda functions.

AWS X-Ray is purpose-built for distributed tracing across serverless and microservices architectures. By enabling X-Ray tracing directly on API Gateway and setting Lambda functions to 'active tracing,' X-Ray automatically captures trace data, generates a service map, and provides detailed timing information for each segment, including calls to downstream AWS services like DynamoDB, with minimal manual instrumentation.

Why the other options are wrong

  • A. CloudWatch Logs provides logs but does not offer distributed tracing across services or a visual service map to identify bottlenecks in a multi-service transaction.
  • C. This involves significant manual instrumentation and managing an external OpenTelemetry collector, which goes against the goal of minimizing manual instrumentation and leveraging native AWS services for serverless tracing.
  • D. While EMF is useful for custom metrics, it does not provide distributed tracing, service maps, or the detailed segment-level timing that X-Ray offers for end-to-end transaction analysis.

AWS X-Ray Active Tracing (Lambda)

A setting for AWS Lambda functions that automatically instruments the function and its calls to other AWS services, sending trace data to X-Ray without explicit SDK calls in the function code.

  • Automatically traces invocations and downstream AWS service calls.
  • Generates segments for each part of the execution.
  • Requires minimal configuration, not manual SDK instrumentation.

Memory trick: X-Ray eXplores eVery Lambda eXecution.

More Monitoring and Logging questions