Syntax
Java
NewRelic.incrementAttribute(string $name[, float $value])
Kotlin [#kotlin]
NewRelic.incrementAttribute(name: String!, value : Double)
Description [#description]
Increments the count of an attribute. Overwrites its previous value and type each time it is called.
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.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute. |
|
| Optional. The attribute is incremented by this float value. |
Return values [#return-values]
Returns true
if recorded successfully, or false
if not.
Examples [#examples]
Here's an example to increment the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:
Java [#java]
boolean incremented = NewRelic.incrementAttribute("rate");
Kotlin [#kotlin]
val incremented = NewRelic.incrementAttribute("rate")
Here's an example to increment the count for the specified attribute by the float value amount:
Java [#java]
boolean incremented = NewRelic.incrementAttribute("rate", 9999.99, false);
Kotlin [#kotlin]
val incremented: Boolean = NewRelic.incrementAttribute("rate", 9999.99)
Syntax
Objective-c
incrementAttribute:(NSString*)name value:(NSNumber*)amount;
Swift [#swift]
NewRelic.incrementAttribute(string $name[, float $value])
Description [#description]
Increments the count of a session attribute. Overwrites previous value and type each time called.
When passed with only a name value, this method increments the count for the specified session 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.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Examples [#examples]
Objective-C [#obj-c]
Here's an example to increment the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:
BOOL incremented = [NewRelic incrementAttribute@"rate"];
Here's another example to increment the count for the specified session attribute by the amount specified in NSNumber*
:
BOOL incremented = [NewRelic incrementAttribute:@"rate" value:@1];
Swift [#swift]
Here's an example to increment the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:
let incremented = NewRelic.incrementAttribute("rate")
Here's another example to increment the count for the specified session attribute by the amount specified in NSNumber!
:
let incremented = NewRelic.incrementAttribute(name: String!, value: NSNumber!)
Syntax
incrementAttribute(options: { name: string; value?: number; }) => void
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
NewRelicCapacitorPlugin.incrementAttribute({ name: 'CapacitorAttribute', value: 15 })
Syntax
incrementAttribute(name: string, value?: number): void;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
NewRelic.incrementAttribute('CordovaCustomAttrNumber'); NewRelic.incrementAttribute('CordovaCustomAttrNumber', 5);
Syntax
RecordCustomEvent(string eventType, string eventName, Dictionary<string, object> attributes): bool;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
// Increment by 1 CrossNewRelic.Current.IncrementAttribute("MAUINumAttr"); // Increment by value CrossNewRelic.Current.IncrementAttribute("MAUINumAttr", 12.3);
Syntax
incrementAttribute(name: string, value?: number): void;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber"); NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber",value :5.0);
Syntax
incrementAttribute(name: string, value?: number): void;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
NewRelic.incrementAttribute('RNCustomAttrNumber'); NewRelic.incrementAttribute('RNCustomAttrNumber', 5);
Syntax
incrementAttribute(string name, float value = 1) : bool;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
// Increment by 1 NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber'); // Increment by value NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber', 5);
Syntax
incrementAttribute(FString name,double value): void;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| The amount to increment the attribute by. |
Example [#example]
// Increment by 1 UNewRelicBPLibrary::incrementAttribute("Unreal Double",5.0);
Syntax
IncrementAttribute(string name, float value = 1) : bool;
Description [#description]
Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.
Parameters [#parameters]
Parameter | Type | Description |
---|---|---|
|
| Required. The name of the attribute to increment. |
|
| Optional. The amount to increment the attribute by. |
Return values [#return-values]
Returns true
if the event is recorded successfully, or false
if not.
Example [#example]
// Increment by 1 CrossNewRelicClient.Current.IncrementAttribute("XamarinNumAttr"); // Increment by value CrossNewRelicClient.Current.IncrementAttribute("XamarinNumAttr", 12.3);