3 Sessions
A span cannot outlive the process being killed, so a session is not a span. It is an identifier stamped on every record, two events, and a summary.
3.1 Identity
Section titled “3.1 Identity”- MUST generate
session.idas a random UUID (version 4 or 7), lowercase, with hyphens. - MUST set
session.previous_idon thesession.startevent when a session follows another one on the same install. - MUST stamp
session.idon records as section 2.4 says.
3.2 Rotation
Section titled “3.2 Rotation”- MUST start a new session when the app returns to the foreground after 30 minutes or more in the background.
- MUST start a new session when the current one reaches 4 hours of total length, at the next foreground transition or record after that point.
- MUST start a new session on every cold start of the process. A process launched in the background (a background fetch, a push notification) MAY defer starting a session until it first comes to the foreground.
- Both durations are policy values (section 12).
3.3 Start and end events
Section titled “3.3 Start and end events”- MUST emit a
session.startlog record when a session begins, withsession.idand, when there is one,session.previous_id. - SHOULD emit
session.endwhen the SDK knows the session ended (rotation while the process lives). - A backend MUST NOT require
session.end. It derives the end from the last record seen and the session summary. - Both events belong to the
summaryfamily (15.1), which is sent for every session unless a backend samples summaries (9.2).
3.4 Session summary
Section titled “3.4 Session summary”Release health (crash-free sessions and users, adoption, session counts) needs every
session, but sampling holds back detail (section 9). The session summary is a
small record of the summary family, sent for every session, sampled or not, so these
numbers are exact rather than reweighted, unless a backend samples summaries to keep within
a usage limit (9.2).
A summary is a log record with event name apsio.session.summary and these attributes:
| Attribute | Type | Required | Value |
|---|---|---|---|
session. |
string | MUST | The session the summary describes |
apsio. |
int | MUST | When the session started, Unix nanoseconds |
apsio. |
string | MUST | active, exited, crashed or abnormal_exit |
apsio. |
int | MUST | Handled errors recorded so far in the session |
apsio. |
boolean | SHOULD | Whether the app was in the foreground when the summary was written |
apsio., apsio., apsio., apsio., apsio. |
SHOULD on a final summary, when known | How the session ended, per section 6.4 | |
apsio. |
string[] | MUST when a trigger fired | The triggers that fired in the session so far, as the policy names them (crash, event:checkout_failed), each once, in the order they fired, at most 20 (15.4) |
apsio. |
string[] | MUST when a capture request releases the session |
The ids of the capture requests releasing the session, each once, in the order the SDK served them, at most 20, kept in every later summary of the session, per 15.5 |
apsio., apsio. |
int, bytes | SHOULD | The session’s highest memory footprint and its 90th percentile, per section 7.6 |
apsio. |
int | SHOULD | Low-memory signals in the session, per section 7.6 |
apsio. |
string | SHOULD | The worst thermal state of the session, per section 7.8 |
apsio. |
boolean | SHOULD | Whether low power mode was on at any time in the session, per section 7.8 |
apsio. (int), apsio. (string[]) |
SHOULD | The milliseconds of the session spent offline, and the connection types seen in it, per section 7.10 | |
apsio. |
int | MUST when any were dropped | The device state, memory warning and connectivity records the SDK did not write over the per-session limit, summed, per section 7.8 |
apsio. |
int | MUST when any were dropped | The bridged log entries the SDK did not write over the rate or the per-session limit, per section 13.7 |
apsio. |
boolean | MUST when true | A log bridge’s read stopped at its time bound, in this session or earlier in its process: some entries came late, or not at all once the bridge stopped, per section 13.7 |
apsio. |
string | SHOULD when known | How the launch that started the session began, per section 8.1; absent for a session that starts on a return from the background |
apsio. (string[]), apsio., apsio., apsio. (string, JSON), apsio. (boolean) |
SHOULD | The session’s screens, requests, screen loads and starts, counted on the device from every record, held or not, per 3.5 | |
apsio., apsio. |
string[] | MUST when the policy has layers | The ids of the layers the device applied when the session started, and of those it was held back from, per section 12.4 |
apsio. (double), apsio. (int, ms) |
SHOULD with battery monitoring on | Charge used in the foreground while not charging, per section 7.9 | |
service., app. |
string | MUST when sent by another launch | The release of the session, per section 2.5 |
The record’s timeUnixNano is the last time the session was seen alive.
- MUST send a summary with outcome
activewhen the session starts. - MUST send a final summary when the outcome is known:
exitedwhen the session rotates or the app terminates normally, or when the next launch reads or infers a termination of a kind that is not a failure (a user quit, an update, a background eviction; section 6.4), with its exit attributes;crashedwhen the next launch finds a crash report for the session (section 6);abnormal_exitwhen the next launch infers or reads a termination without a crash report.
- MAY send more
activesummaries during the session, for example on each move to the background, so the last-seen time stays current if the process is killed. - A backend MUST keep, per session, the summary with the latest
timeUnixNano, except thatcrashedandabnormal_exitare final: a lateractiveorexitedsummary for the same session does not replace them. A final summary sent by the next launch keeps the session’s last-seen time, so at an equaltimeUnixNanoanexitedsummary replaces anactiveone. Between two final summaries of a session, anabnormal_exitsummary whoseapsio.exit.sourceisplatformreplaces anexitedorabnormal_exitone whose source isinferred, whatever theirtimeUnixNano: a platform exit record can arrive after the inference (6.4). Acrashedsummary is never replaced. - A session whose last summary is still
activeafter the rotation timeouts have passed is counted asexited.
3.5 Rollups
Section titled “3.5 Rollups”The policy can hold a family’s detail on the device (section 15), and a backend then has no record of each request or screen load to count. The summary carries the numbers instead: the SDK counts them from every record it writes, held or released, so they stay exact while the detail stays on the device.
apsio.session.screen_path: theapp.screen.nameof eachapp.screen.viewof the session (8.6), in order, a name repeated right after itself written once. At most 50 entries: past that, the 50th entry is…(U+2026) and the rest is left out.apsio.session.rollup.requests: a JSON array with one object per group of the session’s network spans (8.4):method(http.request.method),host(server.address, or the host ofurl.fullwhen it is absent, lower-cased in ASCII, ornonewhen the record has neither),template(url.template, or the template 8.4 derives fromurl.fullwhen it is absent, derived on the device by the same rules),status(the class ofhttp.response.status_code,1xxto5xx, ornonewhen the request got no response),count,p50_msandp90_ms.apsio.session.rollup.screen_loads: a JSON array with one object perapp.screen.nameof the session’sapp.screen.loadspans (8.1):screen,count,p50_msandp90_msof their durations (time to initial display).apsio.session.rollup.app_starts: a JSON array with one object perapp.startspan of the session, in order:type(app.start.type) andms, its duration. At most 20.- Percentiles. Durations are whole milliseconds, rounded down, counted in buckets whose
upper bounds are 50, 100, 150, 200, 300, 400, 500, 750, 1000, 1500, 2000, 3000, 4000, 6000,
8000, 10000, 15000, 20000 and 30000, and a last bucket above 30000.
p50_msandp90_msare the upper bound of the bucket that holds the value of rank ⌈0.5 × count⌉ and ⌈0.9 × count⌉ in ascending order, and the longest duration of the group when that bucket is the last. A device keeps only the counts per bucket and the longest duration, whatever the number of records. - Groups. The objects of
requestsandscreen_loadsare ordered bycount, highest first, then by their other keys in code point order (method,host,template,status). At most 50: past that, the first 49 are kept and the others become one object, withmethod,host,templateandstatus(orscreen) set to*, the sum of their counts and the percentiles of all their durations. - Size. Each rollup is at most 16 KiB of UTF-8 (1.6).
Past that, the SDK leaves out whole objects from the end, never a part of one, and sets
apsio.session.rollup.truncatedtotrue. - MUST count a record that is held, sent or still queued alike, and MUST NOT count a
record it did not write: consent withdrawn, or
captureturned off (12.2). Every summary after the one sent when the session starts carries the rollups of the session so far, so the last one a backend keeps (3.4) has them all; that firstactivesummary MAY omit them. - MUST keep a session’s rollup counts in the store, written as they change or at least on each move to the background, so the final summary the next launch writes for a session that crashed or ended abnormally (3.4) carries the counts kept last. Without them, the sessions that end worst would be the ones that lose their numbers.
- A backend that has a session’s rollups SHOULD take the session’s numbers of requests, screen loads and starts from them rather than from its released records, which can be a sample or a trigger’s window, and MUST NOT add the two. The released records stay the detail behind the numbers.
The function session.rollup (B.2) fixes the groups, their
order and the percentiles.