Skip to content
apsio/ specApsio Mobile Profile, homev0.1.0 · final
GitHub

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.

  • 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.
  • A metric point’s start and end are the report’s window: timeRange (Swift API) or timeStampBegin and timeStampEnd (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.
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, min or max values the source did not report. A histogram point from MetricKit has count and bucketCounts, and no sum.
  • Metric names are apsio.metrickit.<metric>, in snake case, with the unit in the OTLP unit field (for example apsio.metrickit.time_to_first_draw, unit ms).
  • Hitch time ratios are in milliseconds of hitch per second, unit ms/s: apsio.metrickit.scroll_hitch_time_ratio (MXAnimationMetric.scrollHitchTimeRatio) and apsio.metrickit.hitch_time_ratio (MXAnimationMetric.hitchTimeRatio from iOS 26, or HitchTimeMetric’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 as apsio.exit.reason (section 6.4), apsio.exit.foreground (true for the foreground counters) and the counter’s name as apsio.exit.platform_reason. The counters map to reasons as follows; a counter not in the table is unknown:
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
  • 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 carry apsio.metrickit.multiple_versions = true; its service.version is then the latest one only.

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.

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 set apsio.memory.footprint.kind to rss wherever 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.view record. 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 at warning or critical. 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, onTrimMemory at TRIM_MEMORY_RUNNING_LOW or TRIM_MEMORY_RUNNING_CRITICAL, or onLowMemory;
    • 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 from false to true is one warning.

    SHOULD count the session’s warnings in the summary’s apsio.memory.warning_count, and record each as an apsio.device.memory_warning event (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.

  • SHOULD set the device’s physical memory as the Resource attribute apsio.device.memory.total, in bytes: iOS ProcessInfo.physicalMemory, Android ActivityManager.MemoryInfo.totalMem.

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.memory.footprint int, bytes 7.6
apsio.cpu.utilization 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.battery.level double, 0 to 1 With battery monitoring on (7.9)
apsio.battery.charging boolean With battery monitoring on (7.9)
apsio.device.thermal_state string 7.8
apsio.device.low_power boolean 7.8
app.screen.name string The screen in front
Attribute Values iOS Android
apsio.device.thermal_state 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.device.low_power boolean ProcessInfo.isLowPowerModeEnabled PowerManager.isPowerSaveMode()
  • SHOULD record each change of either as a log record with event name apsio.device.thermal_state or apsio.device.low_power, carrying the new value, and each memory warning (7.6) as a log record with event name apsio.device.memory_warning. These records are in the logs family, and are recorded whatever the mode of the resources family.
  • Limit. An SDK MUST NOT write more than 50 records of each of apsio.device.thermal_state, apsio.device.low_power, apsio.device.memory_warning and apsio.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, as apsio.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 function device_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, and apsio.device.low_power.seen, true when low power mode was on at any time in the session. These, like apsio.memory.warning_count (7.6) and the connectivity summary (7.10), count every change, those over the limit included.

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.storage.app The app bundle StorageStats.getAppBytes(), from API 26
apsio.storage.data 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.storage.cache Library/Caches getCacheBytes(), from API 26
apsio.storage.free Omitted (see below) StorageManager.getAllocatableBytes() from API 26, StatFs.getAvailableBytes() before
apsio.storage.total 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.isBatteryMonitoringEnabled is 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_CHANGED broadcast 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, and apsio.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.

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.connection.type 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.connection.subtype 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.carrier.name, network.carrier.mcc, network.carrier.mnc, network.carrier.icc 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.type or network.connection.subtype as a log record with event name apsio.device.connectivity, carrying the new values (and the carrier ones on cell), in the logs family whatever the mode of resources, 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 unavailable to the next change away from it, or to the end of the session. The session summary carries apsio.session.offline_ms, the milliseconds of the session spent offline, and apsio.session.connection_types, the values of network.connection.type seen in the session, each once (3.4). The reference function connectivity.periods (B.2) fixes both.

  • A network span carries network.connection.type and network.connection.subtype as they were when the request started (8.4).

  • A rule can fire on apsio.device.connectivity with a condition on network.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 triggers as rule:offline.

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.device.locale string, BCP 47 The locale the app runs in: Locale.current.identifier(.bcp47) Locale.getDefault().toLanguageTag()
apsio.device.region string, ISO 3166-1 alpha-2 Locale.current.region (regionCode before iOS 16) Locale.getDefault().country
apsio.device.orientation string: portrait, landscape The interface orientation of the scene in front Configuration.orientation
apsio.device.appearance string: light, dark UITraitCollection.userInterfaceStyle of the scene in front Configuration.uiMode night bits
apsio.device.font_scale 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.locale and apsio.device.region on 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 the logs family whatever the mode of resources, 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 severity INFO.
  • 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.