Syntax
NewRelic.Api.Agent.NewRelic.AddCustomParameter(string $key, string $value)NewRelic.Api.Agent.NewRelic.AddCustomParameter(string $key, IConvertible $value)
Attaches a custom attribute (a key/value pair) to the current transaction.
Requirements
Caution
This API has been deprecated. Please use the AddCustomAttribute
instead.
Compatible with all agent versions.
Must be called inside a transaction.
Description
Attaches a custom attribute (a key/value pair) to the current transaction. For the attribute value, you can report either a string or an IConvertible. (The call name is AddCustomParameter
because "custom attributes" were previously called "custom parameters.")
Custom attributes can be used to add more detail and context to errors and transaction traces that are being reported to New Relic. For example, you might add a user name attribute to a transaction to help you filter and analyze your data. You can attach up to 64 attributes per transaction. (Each call to this API method counts as one "user" attribute.) You can also attach (or "forward") these attributes to Browser monitoring's PageView events.
For more information, see .NET agent attributes.
Important
If you want to use your custom parameters or attributes, avoid using any of the reserved terms used by NRQL.
Parameters
Parameter | Description |
---|---|
| |
string | Required. The key name to add to the transaction attributes. Only the first 255 characters are retained. |
string | Required. The string value to add to the current transaction. There is a 255 character limit. Values that exceed this limit will be discarded. |
| |
string | Required. The key name to add to the transaction attributes. Only the first 255 characters are retained. |
IConvertible | Required. The numeric value to add to the current transaction. For NRQL functions that require a numeric value (such as |
Examples
Record a numeric value
NewRelic.Api.Agent.NewRelic.AddCustomParameter("UserGuid", (Single)1234);
Record a string value
NewRelic.Api.Agent.NewRelic.AddCustomParameter("UserName", "Data Nerd");
Record both numeric and string value
To record attributes for a coupon code (string) and an item ID code (single), you could include this code in the parent method:
NewRelic.Api.Agent.NewRelic.AddCustomParameter("Discount Code", "Summer Super Sale");NewRelic.Api.Agent.NewRelic.AddCustomParameter("Item Code", (Single)31456);
For more help
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.