• /
  • Log in
  • Free account

incrementAttribute (iOS SDK API)

Syntax

incrementAttribute:(NSString*)name value:(NSNumber*)amount;
NewRelic.incrementAttribute(string $name[, float $value])

Increments the count of a session attribute. Overwrites previous value and type each time called.

Requirements

Compatible with all agent versions.

Description

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.

For context on how to use this API, see the documentation about sending custom attributes and events to Insights for:

Parameters

Parameter

Description

$name

string

Required. The name of the session attribute.

$value

float

Optional. The session attribute is incremented by this float value.

Return values

Returns true if recorded successfully, or false if not.

Examples

Objective-C: Increment attribute

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.

Method:

+ (BOOL) incrementAttribute:(NSString*)name;

Example:

BOOL incremented = [NewRelic incrementAttribute@"rate"];

Objective-C: Increment amount

Increments the count for the specified session attribute by the amount specified in NSNumber*.

Method:

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

Example:

BOOL incremented = [NewRelic incrementAttribute:@"rate" value:@1];

Swift: Increment attribute

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.

Method:

NewRelic.incrementAttribute(name: String!) -> Bool

Example:

let incremented = NewRelic.incrementAttribute("rate")

Swift: Increment amount

Increments the count for the specified session attribute by the amount specified in NSNumber!.

Method:

NewRelic.incrementAttribute(name: String!, value: NSNumber!) -> Bool

Example:

let incremented = NewRelic.incrementAttribute(name: String!, value: NSNumber!)
Create issueEdit page
Copyright © 2022 New Relic Inc.