Syntax
NewRelic.incrementAttribute(string $name[, float $value])
Increments the count of an attribute. Overwrites its previous value and type each time it is called.
Requirements
Agent version 5.0.0 or higher.
Description
When passed with only a name value, this method increments the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1. When passed an optional float value, it increments the count for the specified attribute by the float value.
For context on how to use this API, see Send custom attributes and events to Insights.
Parameters
Parameter | Description |
---|---|
string | Required. The name of the attribute. |
float | Optional. The attribute is incremented by this float value. |
Return values
Returns true
if recorded successfully, or false
if not.
Examples
Increment attribute
Increments the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1.
boolean incremented = NewRelic.incrementAttribute("rate");
Increment attribute by specific amount
Increments the count for the specified attribute by the float value amount:
boolean incremented = NewRelic.incrementAttribute("rate", 9999.99, false);