For general information on how the Python agent API calls relate to each other, see the API guide.

Adds one or more custom attributes to a transaction.


This call records one or more custom attributes (a key/value pair attached to your transaction). (The call name is add_custom_parameters because "custom attributes" were previously called "custom parameters.")

Attributes may be found in New Relic APM if the transaction is associated with an error or if a transaction trace is generated for that transaction. Attributes can also be found and queried in New Relic Insights.

Before you create custom attributes, review New Relic's list of reserved terms used by NRQL and Insights.


Parameter Description



Required. Each key is a string (the name of an attribute to add, although only the first 255 characters are retained), and each corresponding value is the value to add to the current transaction for this attribute. Each value can be an int, float, string, or bolean; if a string, only the first 255 characters are retained.

Return value(s)

Returns True if all attributes were added successfully.


Adding custom parameters to background task

An example of adding custom parameters to a background task:

def send_request(): 
	response ='http://URL_path', headers=headers, data=data) 
                'url_path_status_code': response.status_code

Using custom parameters to troubleshoot

You can also use custom parameters to troubleshoot performance issues. For example, you might see occasional slow response times from a pool of memcache instances, but you don't know what instance is causing the problem. You might add an attribute to the transaction indicating the server, like so:

# Set server_ip to be the current server processing the transaction

        'memcache_query_frontend_lookup': server_ip

For more help

Recommendations for learning more: