exam questions

Exam AWS Certified Developer - Associate DVA-C02 All Questions

View all questions & answers for the AWS Certified Developer - Associate DVA-C02 exam

Exam AWS Certified Developer - Associate DVA-C02 topic 1 question 45 discussion

A developer is writing an AWS Lambda function. The developer wants to log key events that occur while the Lambda function runs. The developer wants to include a unique identifier to associate the events with a specific function invocation. The developer adds the following code to the Lambda function:

Which solution will meet this requirement?

  • A. Obtain the request identifier from the AWS request ID field in the context object. Configure the application to write logs to standard output.
  • B. Obtain the request identifier from the AWS request ID field in the event object. Configure the application to write logs to a file.
  • C. Obtain the request identifier from the AWS request ID field in the event object. Configure the application to write logs to standard output.
  • D. Obtain the request identifier from the AWS request ID field in the context object. Configure the application to write logs to a file.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ninomfr64
Highly Voted 1 year ago
Selected Answer: A
Both A and D could work here, as both rely on the context object to get access to execution ID https://docs.aws.amazon.com/us_en/lambda/latest/dg/python-context.html While A uses stoud to send log to CloudWatch Log, D writes to a file. D is less specific (where is the file stored? A single file for each execution?) and looks more comples (manage file(s), manage concurrency access to the file ...), thus I'll go for A
upvoted 15 times
...
Untamables
Highly Voted 1 year, 5 months ago
Selected Answer: A
A https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html https://docs.aws.amazon.com/lambda/latest/dg/nodejs-logging.html There is no explicit information for the runtime, the code is written in Node.js.
upvoted 8 times
Pupina
1 year, 2 months ago
• https://docs.aws.amazon.com/prescriptive-guidance/latest/implementing-logging-monitoring-cloudwatch/lambda-logging-metrics.html • Lambda automatically streams standard output and standard error messages from a Lambda function to CloudWatch Logs, without requiring logging drivers.
upvoted 2 times
...
...
ProcureSense
Most Recent 1 day, 8 hours ago
Selected Answer: A
https://docs.aws.amazon.com/lambda/latest/dg/getting-started.html
upvoted 1 times
...
sumanshu
2 months, 3 weeks ago
Selected Answer: A
A) Correct - The context object contains the AWS request ID, which uniquely identifies each function invocation. Writing logs to standard output ensures they are automatically captured by CloudWatch Logs. B) Eliminated - The event object contains input data passed to the Lambda function but does not include the AWS request ID. Writing logs to a file is not practical in Lambda because the filesystem is ephemeral, and logs stored in files would not persist beyond the function invocation.
upvoted 2 times
...
65703c1
3 months, 3 weeks ago
Selected Answer: A
A is the correct answer.
upvoted 1 times
...
badsati
5 months, 1 week ago
Selected Answer: A
A should work
upvoted 1 times
...
james2033
6 months, 4 weeks ago
Selected Answer: A
See getAwsRequestId() at https://docs.aws.amazon.com/lambda/latest/dg/java-context.html
upvoted 1 times
...
rimaSamir
7 months ago
Tricky question. Sure A and D both can do, but... The question is: why we need to get the request identifier if we will write logs to CloudWatch? So, I will go with answer A.
upvoted 1 times
...
SD_CS
7 months, 2 weeks ago
I think it should be A. Also can anyone advise why the two answers are different ? https://www.examtopics.com/discussions/amazon/view/29007-exam-aws-certified-developer-associate-topic-1-question-26/
upvoted 2 times
...
KarBiswa
9 months ago
The Option A is correct because: The second argument is the context object. A context object is passed to your function by Lambda at runtime. This object provides methods and properties that provide information about the invocation, function, and runtime environment. https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html
upvoted 1 times
...
hsinchang
1 year ago
invocation is in the Context object, and loggging into Standard output, which goes into CloudWatch(more durable, more scalable, etc.), is generally better than using temporary Files
upvoted 1 times
...
Pupina
1 year, 2 months ago
Selected Answer A: Handler function https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html Context object awsRequestId – The identifier of the invocation request. https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html
upvoted 1 times
...
rlnd2000
1 year, 2 months ago
Selected Answer: A
In my opinion both options A and D can fulfill the requirement, since there is no requirement about any specific logging and monitoring tool I will go with defaults (A) because, simple is better than complex :)
upvoted 1 times
...
Prem28
1 year, 3 months ago
Selected Answer: A
The application can write logs to standard output or to a file. Standard output is the default destination for logs. Logs that are written to standard output are sent to Amazon CloudWatch Logs. Logs that are written to a file are stored on the Lambda function's execution environment.
upvoted 5 times
...
Nagendhar
1 year, 4 months ago
Ans: D The code snippet provided in the question is obtaining the request identifier from the context.awsRequestId property, which is available in the context object provided to the Lambda function handler. Therefore, the correct option is: D. Obtain the request identifier from the AWS request ID field in the context object. Configure the application to write logs to a file. This option meets the requirement of logging key events and including a unique identifier to associate the events with a specific function invocation.
upvoted 1 times
...
Rpod
1 year, 4 months ago
Selected Answer: D
Why not D ? Writing logs to a file seems more appropriate than stdout
upvoted 3 times
...
Watascript
1 year, 5 months ago
Selected Answer: A
https://docs.aws.amazon.com/us_en/lambda/latest/dg/python-context.html https://docs.aws.amazon.com/us_en/lambda/latest/dg/python-logging.html
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago