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 |
---|---|
string | Required. The name of the session attribute. |
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!)
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicのデータセキュリティとライセンスドキュメント をご確認ください。