DVA-C02 Question 356
Select 3You are developing a serverless application using AWS Lambda and need to implement observability to monitor application performance and troubleshoot issues effectively. Which of the following actions should you take to instrument your code for observability?
- A
Use AWS X-Ray to trace requests across distributed services by integrating it into your Lambda function.
- B
Log all sensitive user data to Amazon CloudWatch Logs for easier debugging.
- C
Use custom metrics with Amazon CloudWatch to monitor key performance indicators (KPIs) in your Lambda function.
- D
Integrate structured logging using a library like AWS SDK's Logger to provide detailed log context.
- E
Enable AWS Trusted Advisor to monitor real-time metrics for your Lambda function.
Show answer and explanation
Correct answers: A, C, D
Explanation
To instrument your code for observability in AWS Lambda, you should use tools like AWS X-Ray for distributed tracing, Amazon CloudWatch for custom metrics, and structured logging to provide detailed context in logs. These practices help monitor application performance and identify issues effectively, while avoiding actions like logging sensitive user data, which can compromise security.
- A. Correct.
Correct: AWS X-Ray provides distributed tracing capabilities, allowing you to analyze and debug requests that travel through multiple services.
- B. Incorrect.
Incorrect: Logging sensitive user data is a security risk and violates best practices for handling sensitive information. Instead, sensitive data should be masked or omitted from logs.
- C. Correct.
Correct: Custom metrics in Amazon CloudWatch allow tracking of specific KPIs, such as execution time or error rates, which are critical for observability.
- D. Correct.
Correct: Structured logging improves log readability and provides detailed context, making it easier to debug and analyze application behavior.
- E. Incorrect.
Incorrect: AWS Trusted Advisor provides recommendations for cost optimization, security, and performance but does not directly monitor real-time metrics or aid in code-level observability.