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

12 Remote configuration

OpenTelemetry has no remote configuration for apps (OpAMP targets agents and collectors), so the profile defines a small one. It changes what leaves the device, capture and masking without an app release, and can stop an SDK in an incident.

  • MUST fetch the policy with GET /v1/policy from the configuration host, sending Apsio-App-Key and the SDK’s name and version in User-Agent.
  • MUST send If-None-Match with the last ETag it received; the backend answers 304 when nothing changed.
  • MUST fetch at launch, each time the app returns to the foreground (when 60 seconds or more have passed since the last fetch), and every fetch_interval_seconds while the app is in the foreground: 5 minutes by default, never less than 60 seconds. A change made on the backend reaches a device in use within minutes; family modes and rates apply from the next session that starts after it arrives (15.3), the kill switch and remote requests at once.
  • MUST cache the last policy on disk and use it at the next launch until a fetch succeeds.
  • MUST use the defaults of this profile when it has never received a policy, or the policy fails validation.
  • A backend MUST answer with a policy of safe defaults when the app has none configured, never with an error.

A JSON object, validated by schemas/v0.1/policy.schema.json:

{
"version": 7,
"kill_switch": false,
"fetch_interval_seconds": 300,
"session": { "background_timeout_seconds": 1800, "max_length_seconds": 14400 },
"capture": {
"replay": true,
"network_spans": true,
"logs_min_severity": "INFO"
},
"instrumentation": {
"families": {
"summary": { "mode": "always" },
"errors": { "mode": "always" },
"logs": {
"mode": "on_trigger",
"triggers": ["crash", "error", { "trigger": "event:checkout_failed", "window_minutes": 10, "after": "window" }],
"window_minutes": 5,
"retention_hours": 48
},
"spans": { "mode": "sampled", "rate": 0.25 },
"network": { "mode": "sampled", "rate": 0.25, "triggers": ["rule:checkout_5xx"] },
"metrics": { "mode": "always" },
"replay": { "mode": "sampled", "rate": 0.1, "retention_hours": 6, "cap_bytes": 5242880 }
},
"rules": [
{
"id": "checkout_5xx",
"on": "network",
"where": [
{ "attr": "url.template", "op": "eq", "value": "/checkout" },
{ "attr": "http.response.status_code", "op": "status_class", "value": "5xx" }
]
}
],
"retention_hours": 24,
"cap_bytes": 20971520,
"replay_cap_bytes": 10485760
},
"requests": [
{
"id": "0192f3a4-0000-7000-8000-00000000e001",
"kind": "send",
"match": "2c65fb7c182f4ccb0cf9ac08da9bb0d7c5b30b22d386a01699008d10d948cad6",
"expires_at": 1792540800
}
],
"layers": [
{
"id": "0192f3a4-0000-7000-8000-00000000f001",
"when": { "app_version": ["5.2.0"], "os_name": ["iOS"] },
"rollout": { "percent": 10, "holdback_percent": 5 },
"instrumentation": { "families": { "network": { "mode": "always" } } }
}
],
"replay": { "max_minutes_per_session": 5 },
"masking": { "mask_classes": [], "hide_classes": [] }
}
  • version increases with each change. An SDK MUST ignore a policy whose version is lower than the one it has.
  • Unknown fields MUST be ignored, so newer backends can add fields.
  • instrumentation decides, per family, what leaves the device and when, how long the rest stays on it and how much it may hold; requests carries remote send, delete and capture requests (section 15). instrumentation.families sets each family’s mode (always, sampled with a rate, on_trigger with triggers and window_minutes, or never); a trigger in triggers is a name, or an object that sets its own window_minutes and whether it releases the rest of the session (after, 15.4). rules defines up to 50 triggers of the policy’s own, each a predicate over the records as they are written, that families list as rule:<id> (15.8). retention_hours is 1 to 168 (24 by default); cap_bytes is at most 20 MiB and replay_cap_bytes at most 10 MiB, their defaults. A family can set its own retention_hours (1 to 168) and cap_bytes (at least 64 KiB), which apply to its records instead (15.6). A request has an id (a UUID), a kind (send, delete or capture, which also has sessions, 1 to 20), a match, optional families and expires_at (Unix seconds); the list holds at most 100.
  • masking and replay.max_minutes_per_session can only tighten (section 10.5): a replay.max_minutes_per_session above the SDK’s limit of 5 changes nothing (10.6). An absent field tightens nothing. A backend MUST omit masking.text unless the app’s owner chose to force it: "all" voids every unmask the app set, so a default of "all" would undo them all.
  • A backend that lets the app’s owner set masking.mask_classes or masking.hide_classes SHOULD warn, when the owner names a class, that a minified Android app must keep that class’s name (-keepnames) and a Swift class needs its module prefix: a name that does not resolve in the app records every session with replay in strict mode (10.4).
  • capture can turn collection off or narrow it; it MUST NOT turn on capture the app turned off in code.
  • layers change part of the policy for some devices only: those a layer targets, and a share of them for a staged rollout (12.4).
  • live, optional, turns on live inspection for the testers it lists (section 16): origin, an HTTPS origin of a lowercase host and an optional port (1 to 65535), or for local testing a loopback HTTP one (16.4), and testers, at most 100, each an id (a UUID), a match (the SHA-256 of the entry’s proof, 16.1) and expires_at (Unix seconds). Without it live inspection is off. An SDK that does not implement section 16 ignores it.
  • When kill_switch is true, the SDK MUST stop collecting, drop its queue and its store (15.6) and send nothing until a later policy turns it off. It keeps fetching the policy at the normal interval.
  • The kill switch takes effect at the next successful fetch.

A layer changes part of the policy for the devices it targets, and for a share of them when it rolls out in stages. The backend publishes one policy for every device of an app; each device works out which layers apply to it.

  • A layer has an id (a UUID), an optional when, an optional rollout, an optional expires_at (Unix seconds), and the parts of the policy it changes: capture, instrumentation, replay and masking. Other keys in a layer MUST be ignored. In instrumentation, a layer changes only families: rules are defined once, in the base instrumentation.rules (15.8), and a layer’s families list them as rule:<id>, so a layer targets a rule to some devices by listing it. The list holds at most 50 layers.
  • when targets devices. Each key narrows the layer, and a layer without when targets every device:
    • app_version: values of service.version;
    • os_name, os_version_min, os_version_max: as the Resource writes os.name and os.version, compared as dotted numbers;
    • device_model: values of device.model.identifier;
    • match: up to 100 hashes, each the lowercase hex SHA-256 of the layer’s id, a colon, and an app.installation.id or a user.hash, as for remote requests (15.5). A layer matched by a user.hash applies only while the app has set that hash.
  • rollout stages the layer. percent (0 to 100, two decimals) is the share of targeted installs that take it; holdback_percent (0 to 50) is a share kept out of it on purpose, to compare against. The device places itself with the layer’s bucket: the first 8 bytes of the SHA-256 of apsio.layer:, the layer’s id, a colon and its app.installation.id, read as an unsigned big-endian integer, modulo 10000. A bucket below holdback_percent × 100 is in the holdback and does not take the layer; a bucket from there below (holdback_percent + percent) × 100 takes it; any other bucket does not. Without an installation id the device takes no staged layer.
  • The device applies the base policy, then each layer that applies to it in list order: a later layer wins. Objects merge key by key; a family in instrumentation.families is replaced whole, with its triggers, their windows and its own retention and cap, so a layer that changes what a family keeps or what its triggers release names the whole family. Layers obey the rules of the base: capture only narrows what the app set, masking and replay only tighten (12.2).
  • The session summary carries apsio.policy.layers, the ids of the layers the device applied, and apsio.policy.holdback, the ids of the layers it was held back from, so the backend can compare the two groups. Both are the layers as they stood when the session started, the same in every summary of the session: they decided its modes and rates (15.3). A layer that comes to apply during the session, from a fetch or from a user.hash the app sets then, changes what applies once fetched and is listed from the next session; such a session counts in neither group for that layer, which a comparison of the two groups accepts.
  • Guardrails run on the backend: it watches the applied and holdback groups (crash-free sessions, ingest volume) and, past a bound the app’s owner set, publishes a policy without the layer. A device rolls back at its next fetch, so it never needs the bound.