• Log inStart now

recordMetric (iOS SDK API)


NewRelic recordMetricWithName:(NSString *)name category:(NSString *)category value:(NSNumber *)value];
NewRelic.recordMetric(withName: String!, category: String!, value: NSNumber!)

Record custom metrics (arbitrary numerical data).


Compatible with all agent versions.


With this method, you can record arbitrary custom metrics to give more detail about app activity that is not tracked by New Relic automatically. The call accepts several sets of parameters for optional levels of detail.

This method will record a metric of the form Custom/[Category]/[Name], with a count of 1 and a total value equal to the value passed in. Multiple calls will aggregate the count and value according to standard metric aggregation rules for mobile monitoring.

To get the most out of your metrics, follow these guidelines to create clear, concise metric names:

  • Use case and whitespace characters appropriate for display in the user interface. Metric names are rendered as-is.
  • Capitalize the metric name.
  • Avoid using the characters / ] [ | * when naming metrics.
  • Avoid multi-byte characters.

The category is also required; it is displayed in the UI and is useful for organizing custom metrics if you have many of them. It can be a custom category or it can be a predefined category using the MetricCategory enum.

For variations that accept additional arguments and give you more control over the metrics you record, see NewRelic.h. For more information about using this API, see the iOS SDK API usage guide.






Required. The name for the custom metric.



Required. The metric category name, either custom or using a predefined metric category.



Required. The value of the metric.




[NewRelic recordMetricWithName:(NSString *)name
category:(NSString *)category
value:(NSNumber *)value];

Example (metrics in milliseconds):

[NewRelic recordMetricWithName:(NSString *)@"My Important Metric"
category:(NSString *)@"Important Metrics"
value:(NSNumber *)145.67];



NewRelic.recordMetric(withName: String!, category: String!, value: NSNumber!)

Example (metrics in milliseconds):

NewRelic.recordMetric(withName: "My Important Metric", category: "Important Metrics", value: 145.67)
Copyright © 2023 New Relic Inc.

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