Relic Solution: Configuring custom attributes and events in AWS Lambda

In this series, we’ve covered alerting on Lambda functions in NRONE. In addition to monitoring their Lambda for certain benchmarks, customers also want to set up their own events or attributes besides the data we provide by default. This process is agent-specific due to the nature of the languages, so each process has its own section. One thing to note is all the agents require a Lambda handler to create custom anything. Now let’s get started!

Go Agent

The Go agent team set up the Lambda with the agent so setting custom attributes and events are the same as in the agent. It’s worth noting the Go native txn.Application() method is useful to get the application. You use the API calls listed here:

txn.AddAttribute(“userLevel”, “gold”)

txn.Application().RecordCustomEvent(“MyEvent”, map[string]interface{}{

Node Agent

Setting custom attributes and events are the same as with the agent. You use the following API calls:

module.exports.handler = newrelic.setLambdaHandler(

newrelic.recordCustomEvent('myNREvent', { foo: 'bar' });


  "Discount Code": "Summer Super Sale",

  "Item Code": 31456


Python Agent

Works the same as the agent. You can use the following API calls:


def lambda_handler(event, context):

newrelic.agent.record_custom_event(‘demotronLambdaPython’, {“zalikaLambdatest”}

newrelic.agent.record_custom_event(‘zalikaLambdatest’, my_custom_event)

Java Agent

Currently supports custom attributes using the OpenTracing span API, events are currently not supported:

Span span = tracer.buildSpan(“say-hello”).startManual();

span.setTag(“hello-to”, “Bryan”);

.Net agent

It supports custom attributes but not events:

GlobalTracer.Instance.ActiveSpan.SetTag(“mycustomAttr”, “value”);


The Node example doesn’t make sense.

  1. It’s not syntactically valid.

  2. Where is setLambdaHandler documented? Not here or here.

  3. It doesn’t explain what the custom attributes will be attached to. Piecing it together from other sources, I think it would be an AwsLambdaInvocation event that’s automatically emitted?

Hi @jesse.mccarthy

Thank you for mentioning the issue.

As described [here] looks like in @DoctorWho example is missing the require('@newrelic/aws-sdk');.

Can you test, please?



Hi @rcorgozinho, thanks for your reply.

As I mentioned, the example code is not even syntactically valid, so adding another statement is not going to make it work.

You’re referring to “Option #4: Manually instrument Lambda code for Go, Java, .NET Core, Node.js, and Python”?

That documentation doesn’t match up with the README for the @newrelic/aws-sdk package, which indicates that it should be unnecessary to explicitly install or require it when using the newrelic agent package.

It also refers to @newrelic/aws-sdk as “the AWS SDK”, which it isn’t – it’s your instrumentation for the AWS SDK. That’s a really confusing thing to do, I would recommend not doing that anywhere in your documentation.

Aside from those issues, I’m not at the point of testing this – I’m evaluating whether I even want to attempt this with your service or go with another solution that’s clearer.