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.
12.1 Fetching
Section titled “12.1 Fetching”- MUST fetch the policy with
GET /v1/policyfrom the configuration host, sendingApsio-App-Keyand the SDK’s name and version inUser-Agent. - MUST send
If-None-Matchwith the last ETag it received; the backend answers304when 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_secondswhile 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.
12.2 The document
Section titled “12.2 The document”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": [] }}versionincreases 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.
instrumentationdecides, per family, what leaves the device and when, how long the rest stays on it and how much it may hold;requestscarries remotesend,deleteandcapturerequests (section 15).instrumentation.familiessets each family’smode(always,sampledwith arate,on_triggerwithtriggersandwindow_minutes, ornever); a trigger intriggersis a name, or an object that sets its ownwindow_minutesand whether it releases the rest of the session (after, 15.4).rulesdefines up to 50 triggers of the policy’s own, each a predicate over the records as they are written, that families list asrule:<id>(15.8).retention_hoursis 1 to 168 (24 by default);cap_bytesis at most 20 MiB andreplay_cap_bytesat most 10 MiB, their defaults. A family can set its ownretention_hours(1 to 168) andcap_bytes(at least 64 KiB), which apply to its records instead (15.6). A request has anid(a UUID), akind(send,deleteorcapture, which also hassessions, 1 to 20), amatch, optionalfamiliesandexpires_at(Unix seconds); the list holds at most 100.maskingandreplay.max_minutes_per_sessioncan only tighten (section 10.5): areplay.max_minutes_per_sessionabove the SDK’s limit of 5 changes nothing (10.6). An absent field tightens nothing. A backend MUST omitmasking.textunless 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_classesormasking.hide_classesSHOULD 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). capturecan turn collection off or narrow it; it MUST NOT turn on capture the app turned off in code.layerschange 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), andtesters, at most 100, each anid(a UUID), amatch(the SHA-256 of the entry’s proof, 16.1) andexpires_at(Unix seconds). Without it live inspection is off. An SDK that does not implement section 16 ignores it.
12.3 Kill switch
Section titled “12.3 Kill switch”- When
kill_switchistrue, 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.
12.4 Layers: targeting and staged rollout
Section titled “12.4 Layers: targeting and staged rollout”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 optionalwhen, an optionalrollout, an optionalexpires_at(Unix seconds), and the parts of the policy it changes:capture,instrumentation,replayandmasking. Other keys in a layer MUST be ignored. Ininstrumentation, a layer changes onlyfamilies: rules are defined once, in the baseinstrumentation.rules(15.8), and a layer’s families list them asrule:<id>, so a layer targets a rule to some devices by listing it. The list holds at most 50 layers. whentargets devices. Each key narrows the layer, and a layer withoutwhentargets every device:app_version: values ofservice.version;os_name,os_version_min,os_version_max: as the Resource writesos.nameandos.version, compared as dotted numbers;device_model: values ofdevice.model.identifier;match: up to 100 hashes, each the lowercase hex SHA-256 of the layer’sid, a colon, and anapp.installation.idor auser.hash, as for remote requests (15.5). A layer matched by auser.hashapplies only while the app has set that hash.
rolloutstages 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 ofapsio.layer:, the layer’sid, a colon and itsapp.installation.id, read as an unsigned big-endian integer, modulo 10000. A bucket belowholdback_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.familiesis 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:captureonly narrows what the app set,maskingandreplayonly tighten (12.2). - The session summary carries
apsio.policy.layers, the ids of the layers the device applied, andapsio.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 auser.hashthe 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.