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' });



newrelic.addCustomAttributes({



  "Discount Code": "Summer Super Sale",



  "Item Code": 31456



});

Python Agent

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

@newrelic.agent.lambda_handler()

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”);

4 Likes