• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Increment session attribute count

Syntax

Java

NewRelic.incrementAttribute(string $name[, float $value])

Kotlin

NewRelic.incrementAttribute(name: String!, value : Double)

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

Parameter

Type

Description

$name

string

Required. The name of the attribute.

$value

float

Optional. The attribute is incremented by this float value.

Return values

Returns true if recorded successfully, or false if not.

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

boolean incremented = NewRelic.incrementAttribute("rate");

Kotlin

val incremented = NewRelic.incrementAttribute("rate")

Here's an example to increment the count for the specified attribute by the float value amount:

Java

boolean incremented = NewRelic.incrementAttribute("rate", 9999.99, false);

Kotlin

val incremented: Boolean = NewRelic.incrementAttribute("rate", 9999.99)

Syntax

Objective-c

incrementAttribute:(NSString*)name value:(NSNumber*)amount;

Swift

NewRelic.incrementAttribute(string $name[, float $value])

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

amount

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Examples

Objective-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

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

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Example

NewRelicCapacitorPlugin.incrementAttribute({ name: 'CapacitorAttribute', value: 15 })

Syntax

incrementAttribute(name: string, value?: number): void;

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Example

NewRelic.incrementAttribute('CordovaCustomAttrNumber');
NewRelic.incrementAttribute('CordovaCustomAttrNumber', 5);

Syntax

RecordCustomEvent(string eventType, string eventName, Dictionary<string, object> attributes): bool;

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

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

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Example

NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber");
NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber", value :5.0);

Syntax

incrementAttribute(name: string, value?: number): void;

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Example

NewRelic.incrementAttribute('RNCustomAttrNumber');
NewRelic.incrementAttribute('RNCustomAttrNumber', 5);

Syntax

incrementAttribute(string name, float value = 1) : bool;

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Example

// Increment by 1
NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber');
// Increment by value
NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber', 5);

Syntax

incrementAttribute(FString name,double value): void;

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

The amount to increment the attribute by.

Example

// Increment by 1
UNewRelicBPLibrary::incrementAttribute("Unreal Double",5.0);

Syntax

IncrementAttribute(string name, float value = 1) : bool;

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

Parameter

Type

Description

name

string

Required. The name of the attribute to increment.

value

number

Optional. The amount to increment the attribute by.

Return values

Returns true if the event is recorded successfully, or false if not.

Example

// Increment by 1
CrossNewRelicClient.Current.IncrementAttribute("XamarinNumAttr");
// Increment by value
CrossNewRelicClient.Current.IncrementAttribute("XamarinNumAttr", 12.3);
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.