New Relic Integration for Mobile App Monitoring (APM)
New Relic Mobile is one of the few APM tools where the mobile client and backend live in the same account without additional correlation setup. If your backend already has New Relic APM, the mobile part integrates into the same entity hierarchy, and Distributed Tracing works almost out of the box.
Agent Installation
iOS via Swift Package Manager:
// Package.swift
.package(url: "https://github.com/newrelic/newrelic-ios-agent-spm", from: "7.4.0")
import NewRelic
// AppDelegate.application(_:didFinishLaunchingWithOptions:)
NewRelic.start(withApplicationToken: "AA-XXXXXXXX-XXXX")
The agent automatically intercepts URLSession requests via swizzling. If you use a custom URLProtocol or Alamofire with custom adapters, verify that swizzling doesn't conflict.
Android:
// build.gradle (project level)
classpath("com.newrelic.agent.android:agent-gradle-plugin:7.+")
// build.gradle (app level)
apply plugin: 'newrelic'
implementation("com.newrelic.agent.android:android-agent:7.+")
// MainActivity or Application.onCreate()
NewRelic.withApplicationToken("AA-XXXXXXXX-XXXX")
.withLoggingEnabled(false)
.start(applicationContext)
The Gradle plugin instruments bytecode during build — HTTP calls via OkHttp and HttpURLConnection start tracking without code changes. Convenient, but sometimes causes ProGuard issues: add rules for classes com.newrelic.** in proguard-rules.pro.
Interaction with Distributed Tracing
New Relic passes the newrelic header (W3C TraceContext) to all outgoing requests. On the backend, New Relic APM agent captures this header and forms a single trace. In New Relic One UI, you can open a specific HTTP request from the mobile app and drill down to the server trace at the SQL level.
Important: Distributed Tracing for New Relic mobile agents is enabled by default only for Infinite Tracing (if a Trace Observer is configured). For standard sampling, enable it explicitly:
NewRelic.enableFeatures([.NRFeatureFlag_DistributedTracing])
Custom Events and Attributes
// Custom event
NewRelic.recordCustomEvent(
"CheckoutCompleted",
attributes: [
"order_id": orderId,
"total": total,
"payment_method": method
]
)
// Add attribute to current session
NewRelic.setAttribute("user_plan", value: "premium")
Android equivalents:
NewRelic.recordCustomEvent(
"CheckoutCompleted",
mapOf("order_id" to orderId, "total" to total)
)
Custom events go into NRQL — New Relic's query language. For example:
SELECT count(*) FROM CheckoutCompleted
FACET payment_method
SINCE 7 days ago
TIMESERIES
Error and Crash Tracking
New Relic Mobile collects crashes automatically. Record handled exceptions explicitly:
do {
try performPayment()
} catch {
NewRelic.recordError(error, attributes: ["context": "checkout"])
}
Crash reports in New Relic include Thread State for all threads, Application Not Responding events, and Breadcrumb Trail — the sequence of navigation and network events before the crash.
Dashboards and Alerts
New Relic Alerts lets you set up NRQL conditions:
-- Alert if crash-free rate drops below 99.5%
SELECT percentage(count(*), WHERE crashCount = 0)
FROM MobileSession
WHERE appName = 'MyApp'
Unlike Firebase Crashlytics, you can set an alert not just on crash count, but on business metrics — for example, checkout conversion drop correlated with network error rate.
What We Do
- Connect agent for iOS/Android (or React Native via
@newrelic/react-native-agent) - Verify correct HTTP auto-instrumentation
- Configure Distributed Tracing with backend agent
- Create custom events for your business funnel
- Set up NRQL alerts with Slack/PagerDuty notifications
Timeline
Basic integration with auto-instrumentation: 1–2 days. Custom events and dashboards: another 1 day. Pricing is calculated individually.







