DVA-C02 Question 355
Select 3You are developing a serverless application using AWS Lambda and want to monitor its performance and troubleshoot issues effectively. Which actions should you take to instrument your code for observability?
- A
Use AWS X-Ray SDK to trace requests through your Lambda function and other AWS services.
- B
Log custom metrics to Amazon CloudWatch by using the AWS SDK for CloudWatch.
- C
Enable AWS Lambda's built-in logging feature to automatically correlate logs with traces.
- D
Manually send error details to an external monitoring tool instead of using AWS services.
- E
Add structured logging to your Lambda code to include details like request IDs, timestamps, and error messages.
Show answer and explanation
Correct answers: A, B, E
Explanation
Observability for AWS Lambda involves using tools such as AWS X-Ray for tracing, Amazon CloudWatch for logging and custom metrics, and structured logging to add meaningful context to application logs. Together, these practices enable monitoring, debugging, and troubleshooting in a serverless environment.
- A. Correct.
Using AWS X-Ray SDK helps trace requests through your Lambda function and integrated AWS services, providing end-to-end observability.
- B. Correct.
Logging custom metrics to CloudWatch allows you to monitor application-specific performance metrics and set alarms if needed.
- C. Incorrect.
AWS Lambda does not automatically correlate logs with traces. You need to use AWS X-Ray for tracing and add structured logging for correlation.
- D. Incorrect.
Sending error details to an external monitoring tool is not recommended when AWS provides integrated observability solutions like CloudWatch and X-Ray.
- E. Correct.
Structured logging helps capture meaningful log data, making it easier to debug and correlate logs with traces or metrics.