Now that we have intentionally instituted an error in our code, let’s take a look at how New Relic for AWS Lambda’s distributed tracing feature can help us diagnose problems like this that might occur in the real world.
Hop on over to the distributed tracing page by clicking on the Distributed tracing link located in the navigation menu on the left side of the screen in the section labeled MONITOR:
New Relic automatically groups your traces by type. Click on the checkbox next to NameError, then click on the name of the trace group located in the Trace groups table at the bottom of the page:
Now, click on any trace in the list:
Click on the span containing the error (its text will be in red), and then click Error Details to see the actual error thrown by the Lambda function:
We can quickly see that we have an undefined variable named TABLE_NAME within our code.
If you have log forwarding enabled for your function, you can click the See logs button at the top right to see the log entries for the function that occurred exactly when the error took place:
We refer to this as Logs in context:
If you’d like a second pair of eyes to help you diagnose a problem, you can click on the Copy permalink button near the top right hand corner of the screen:
You will notice this permalink button located on many of New Relic’s curated views, allowing you to quickly and easily collaborate with other members of your organization.