7 Vitals and MetricKit
MetricKit delivers pre-aggregated reports about once a day. Reducing them to averages loses the distribution, which is the part teams need. The profile keeps the shape.
7.1 Which API
Section titled “7.1 Which API”- On iOS 27 and later, when the SDK is built with Xcode 27 or later, an SDK SHOULD use
the Swift
MetricManager(metricReports,diagnosticReports). - On iOS 15 to 26, or from an older Xcode, it uses
MXMetricManager. - MUST NOT use both in one process; the same day would be reported twice.
- MUST skip report or metric kinds it does not know, instead of failing.
7.2 Time window
Section titled “7.2 Time window”- A metric point’s start and end are the report’s window:
timeRange(Swift API) ortimeStampBeginandtimeStampEnd(MX*). - With the Swift API, only the full-day entry maps to points. The few-hour interval entries have a duration but no start time; mapping them too would double-count. They stay in the raw payload only.
7.3 Shapes
Section titled “7.3 Shapes”| MetricKit value | OTLP metric | Temporality |
|---|---|---|
| Histograms: time to first draw, resume time, extended launch, hang time, signpost durations | Histogram |
Delta |
| Totals over the window: CPU time, instructions, disk writes, network bytes, foreground time, termination counts | Sum, monotonic |
Delta |
| Peaks, averages and ratios: peak memory, average suspended memory, hitch time ratios | Gauge |
n/a |
- MUST keep every bucket. Bucket ends become
explicitBounds; the count of the last bucket covers everything above the last bound. - MUST NOT invent
sum,minormaxvalues the source did not report. A histogram point from MetricKit hascountandbucketCounts, and nosum. - Metric names are
apsio.metrickit.<metric>, in snake case, with the unit in the OTLPunitfield (for exampleapsio.metrickit.time_to_first_draw, unitms). - Hitch time ratios are in milliseconds of hitch per second, unit
ms/s:apsio.metrickit.scroll_hitch_time_ratio(MXAnimationMetric.scrollHitchTimeRatio) andapsio.metrickit.hitch_time_ratio(MXAnimationMetric.hitchTimeRatiofrom iOS 26, orHitchTimeMetric’s total hitch time over its total animation time with the Swift API). A value reported in another unit is skipped, not converted by guess. - Termination counts are one point per counter, named
apsio.metrickit.terminations, unit{termination}. Each carries the reason asapsio.exit.reason(section 6.4),apsio.exit.foreground(truefor the foreground counters) and the counter’s name asapsio.exit.platform_reason. The counters map to reasons as follows; a counter not in the table isunknown:
MXAppExitMetric (iOS 15 to 26) |
Swift API (iOS 27) | apsio.exit.reason |
|---|---|---|
cumulativeNormalAppExitCount |
normalTerminationCount |
normal |
cumulativeMemoryResourceLimitExitCount |
memoryLimitTerminationCount |
memory |
cumulativeMemoryPressureExitCount (background) |
systemPressureTerminationCount (background) |
memory_pressure |
cumulativeCPUResourceLimitExitCount (background) |
highCPUTerminationCount (background) |
cpu |
cumulativeBadAccessExitCount |
badAccessTerminationCount |
crash |
cumulativeIllegalInstructionExitCount |
illegalInstructionTerminationCount |
crash |
cumulativeAbnormalExitCount |
abnormalTerminationCount |
crash |
cumulativeAppWatchdogExitCount |
watchdogTerminationCount |
watchdog |
cumulativeSuspendedWithLockedFileExitCount (background) |
locked_file |
|
cumulativeBackgroundTaskAssertionTimeoutExitCount (background) |
background_task_timeout |
7.4 Version and session
Section titled “7.4 Version and session”- MetricKit aggregates across all sessions of a day, so its points MUST NOT carry
session.id. - When the report says it includes more than one app version
(
includesMultipleApplicationVersions), the point MUST carryapsio.metrickit.multiple_versions = true; itsservice.versionis then the latest one only.
7.5 Outside Apple platforms
Section titled “7.5 Outside Apple platforms”Android has no MetricKit. Its exits come from ApplicationExitInfo
(section 6.4), its frames from the
opentelemetry-android instrumentations (app.jank, and the start and screen spans of
section 8), and its memory, CPU, storage, battery and thermal state
from sections 7.6 to 7.9, which apply to every platform. Google Play vitals are not
available on the device and are out of scope.
7.6 Memory
Section titled “7.6 Memory”apsio.memory.footprint is the memory the process uses, in bytes, as the platform accounts
for it:
| Platform | Source |
|---|---|
| iOS, iPadOS | phys_footprint of task_vm_info: the value the system compares with the app’s memory limit |
| Android | Debug.getPss(), the proportional set size, in KiB, times 1024 |
-
On Android, MUST read the footprint off the main thread. On a device where reading the proportional set size takes longer than 10 ms, an SDK MAY read the resident set size (
/proc/self/statm) instead, and then MUST setapsio.memory.footprint.kindtorsswherever it sends that footprint. Without the attribute, the footprint is the platform’s value in the table. -
SHOULD read the footprint every 5 seconds while the app is in the foreground, and at each screen view (8.6).
-
SHOULD put the footprint on each
app.screen.viewrecord. An SDK that reads it asynchronously MUST NOT hold the record back for longer than 1 second; the record is then sent without it. -
The session summary (3.4) carries the session’s highest read,
apsio.memory.peak, and its 90th percentile,apsio.memory.p90: the nearest-rank percentile over every read of the session. -
Low-memory signal. A memory warning is the platform telling the app that the system is low on memory:
- on iOS,
didReceiveMemoryWarning, or the memory pressure dispatch source atwarningorcritical. Both usually fire for the same event: a notification and a dispatch source event less than 1 second apart are one warning; - on Android up to API 33,
onTrimMemoryatTRIM_MEMORY_RUNNING_LOWorTRIM_MEMORY_RUNNING_CRITICAL, oronLowMemory; - on Android from API 34, which no longer delivers those levels,
ActivityManager.MemoryInfo.lowMemory, read at least every 5 seconds in the foreground; each change fromfalsetotrueis one warning.
SHOULD count the session’s warnings in the summary’s
apsio.memory.warning_count, and record each as anapsio.device.memory_warningevent (7.8), within 7.8’s limit of records per session; the count includes the warnings over it. Each platform counts its own signal, so the counts of two platforms are not comparable. - on iOS,
-
SHOULD set the device’s physical memory as the Resource attribute
apsio.device.memory.total, in bytes: iOSProcessInfo.physicalMemory, AndroidActivityManager.MemoryInfo.totalMem.
7.7 Resource snapshots
Section titled “7.7 Resource snapshots”A resource snapshot is a log record with event name apsio.resource.snapshot, in the
resources family (15.1).
- SHOULD write one every 30 seconds while the app is in the foreground, and none in the background.
- It carries these attributes, each omitted when the platform cannot read it:
| Attribute | Type | Value |
|---|---|---|
apsio. |
int, bytes | 7.6 |
apsio. |
double, 0 to 1 | The CPU time the process used since the previous snapshot, in every mode, divided by the time elapsed and by the number of processors (iOS activeProcessorCount, Android Runtime.availableProcessors()). This is the definition of OpenTelemetry’s process.cpu.utilization metric, summed over cpu.mode |
apsio. |
double, 0 to 1 | With battery monitoring on (7.9) |
apsio. |
boolean | With battery monitoring on (7.9) |
apsio. |
string | 7.8 |
apsio. |
boolean | 7.8 |
app. |
string | The screen in front |
7.8 Device state
Section titled “7.8 Device state”| Attribute | Values | iOS | Android |
|---|---|---|---|
apsio. |
nominal, fair, serious, critical |
ProcessInfo.thermalState |
PowerManager.getCurrentThermalStatus(), from API 29: NONE is nominal; LIGHT and MODERATE are fair; SEVERE is serious; CRITICAL, EMERGENCY and SHUTDOWN are critical. Omitted before API 29 |
apsio. |
boolean | ProcessInfo.isLowPowerModeEnabled |
PowerManager.isPowerSaveMode() |
- SHOULD record each change of either as a log record with event name
apsio.device.thermal_stateorapsio.device.low_power, carrying the new value, and each memory warning (7.6) as a log record with event nameapsio.device.memory_warning. These records are in thelogsfamily, and are recorded whatever the mode of theresourcesfamily. - Limit. An SDK MUST NOT write more than 50 records of each of
apsio.device.thermal_state,apsio.device.low_power,apsio.device.memory_warningandapsio.device.connectivity(7.10) in a session: the first 50 of each event name, in order. Later ones are counted, not written, and the session summary carries their number, the sum over the four, asapsio.session.device_state_dropped, when any were dropped. A connectivity change undone within 2 seconds (7.10) is not recorded, so it is neither written nor counted. The reference functiondevice_state.capped(B.2) fixes which are written. - The session summary (3.4) carries the session’s worst
thermal state,
apsio.device.thermal_state.worst, andapsio.device.low_power.seen,truewhen low power mode was on at any time in the session. These, likeapsio.memory.warning_count(7.6) and the connectivity summary (7.10), count every change, those over the limit included.
7.9 Storage and battery
Section titled “7.9 Storage and battery”Storage. At most once a day, at a launch and off the main thread, an SDK SHOULD
write a log record with event name apsio.app.storage, in the resources family, with
these attributes in bytes, each omitted when the platform cannot read it:
| Attribute | iOS | Android |
|---|---|---|
apsio. |
The app bundle | StorageStats.getAppBytes(), from API 26 |
apsio. |
The app’s home directory (its sandbox container), without Library/Caches; app group containers are not counted |
getDataBytes() minus getCacheBytes(), from API 26 (the data size includes the cache) |
apsio. |
Library/Caches |
getCacheBytes(), from API 26 |
apsio. |
Omitted (see below) | StorageManager.getAllocatableBytes() from API 26, StatFs.getAvailableBytes() before |
apsio. |
Omitted (see below) | StatFs.getTotalBytes() |
apsio.storage.free is the space the app could allocate, purgeable space included.
iOS omits apsio.storage.free and apsio.storage.total: Apple’s disk-space reasons for its
required-reason APIs don’t allow sending them off the device. The app’s own sizes (app, data,
cache) are the sizes of its files and still go.
Battery. Battery monitoring is the start option battery
(13.1).
- On iOS it is off by default, because
UIDevice.isBatteryMonitoringEnabledis one switch for the whole app. An SDK MUST NOT turn that switch off. - On Android it is on by default: the sticky
ACTION_BATTERY_CHANGEDbroadcast needs no permission and changes nothing for the app. - With monitoring on, the session summary carries
apsio.battery.drain, the percentage points of charge used while the app was in the foreground and not charging, andapsio.battery.drain_duration, the milliseconds it spent so. - iOS reports the battery level in steps of 5 percentage points, so its drain is coarse: a short session or screen can show none, or a whole step.
7.10 Connectivity
Section titled “7.10 Connectivity”How the device reaches the network, with OpenTelemetry’s network.connection.* and
network.carrier.* names, and the periods it had none.
| Attribute | iOS | Android |
|---|---|---|
network. |
NWPathMonitor: unavailable when the path is not satisfied, else wifi, cell or wired by the interface the path uses |
ConnectivityManager.getNetworkCapabilities(activeNetwork): unavailable without an active network, else wifi, cell or wired by its transport |
network. |
On cell, from CTTelephonyNetworkInfo.serviceCurrentRadioAccessTechnology: CTRadioAccessTechnologyNR is nr, NRNSA is nrnsa, LTE is lte, WCDMA is umts, HSDPA hsdpa, HSUPA hsupa, CDMA1x cdma2000_1xrtt, CDMAEVDORev0, RevA, RevB are evdo_0, evdo_a, evdo_b, eHRPD is ehrpd, GPRS gprs, Edge edge |
On cell, TelephonyManager.getDataNetworkType() mapped to OpenTelemetry’s values, only when the app already holds the permission it needs; omitted otherwise |
network., network., network., network. |
Omitted: CTCarrier returns placeholder values from iOS 16 |
On cell: TelephonyManager.getNetworkOperatorName(), the two parts of getNetworkOperator(), and getNetworkCountryIso() in upper case; none of them needs a permission |
-
An SDK MUST NOT ask for a permission to read any of these: what the platform gives without one is recorded, the rest is omitted.
-
SHOULD record each change of
network.connection.typeornetwork.connection.subtypeas a log record with event nameapsio.device.connectivity, carrying the new values (and the carrier ones oncell), in thelogsfamily whatever the mode ofresources, as the records of 7.8, and within 7.8’s limit of 50 per session. A change that is undone within 2 seconds is not recorded, so a network that flaps leaves one record. The first record of a session carries the state at its start. -
An offline period is the time from a change to
unavailableto the next change away from it, or to the end of the session. The session summary carriesapsio.session.offline_ms, the milliseconds of the session spent offline, andapsio.session.connection_types, the values ofnetwork.connection.typeseen in the session, each once (3.4). The reference functionconnectivity.periods(B.2) fixes both. -
A network span carries
network.connection.typeandnetwork.connection.subtypeas they were when the request started (8.4). -
A rule can fire on
apsio.device.connectivitywith a condition onnetwork.connection.type, so a family’s window is released when the device goes offline or onto a cellular network (15.8). A rule fires at most once a session, so only the first offline period releases:{ "id": "offline", "on": "log:apsio.device.connectivity","where": [{ "attr": "network.connection.type", "op": "eq", "value": "unavailable" }] }listed in a family’s
triggersasrule:offline.
7.11 Device context
Section titled “7.11 Device context”How the user has set up the device, so issues and timings split by language, orientation, appearance and text size.
| Attribute | Type | iOS | Android |
|---|---|---|---|
apsio. |
string, BCP 47 | The locale the app runs in: Locale.current.identifier(.bcp47) |
Locale.getDefault().toLanguageTag() |
apsio. |
string, ISO 3166-1 alpha-2 | Locale.current.region (regionCode before iOS 16) |
Locale.getDefault().country |
apsio. |
string: portrait, landscape |
The interface orientation of the scene in front | Configuration.orientation |
apsio. |
string: light, dark |
UITraitCollection.userInterfaceStyle of the scene in front |
Configuration.uiMode night bits |
apsio. |
double | The text size category, as the table below maps it | Configuration.fontScale |
iOS has text size categories, not a scale; the SDK maps each to the ratio of its body text size to the default’s (17 points):
| Category | Scale | Category | Scale |
|---|---|---|---|
extraSmall |
0.82 | extraExtraExtraLarge |
1.35 |
small |
0.88 | accessibilityMedium |
1.65 |
medium |
0.94 | accessibilityLarge |
1.94 |
large (the default) |
1.0 | accessibilityExtraLarge |
2.35 |
extraLarge |
1.12 | accessibilityExtraExtraLarge |
2.76 |
extraExtraLarge |
1.24 | accessibilityExtraExtraExtraLarge |
3.12 |
- SHOULD set
apsio.device.localeandapsio.device.regionon the Resource (2.2), as they are at start. - SHOULD record the context as a log record with event name
apsio.device.context, carrying all five attributes, at the start of each session and each time one of them changes, in thelogsfamily whatever the mode ofresources, as the records of 7.8. A change undone within 2 seconds is not recorded, so a rotation back and forth leaves no record. It has no body, and severityINFO. - These are settings of the device, not of the user: none of them identifies anyone, and an SDK MUST NOT add the time zone, the keyboard languages or the user’s other preferred languages.
- A rule (15.8) can read them on
log:apsio.device.context, for example to release the minutes before a session’s switch to landscape on one screen.