Read the console's sampling settings on HarmonyOS - #33
Open
Fiona2016 wants to merge 2 commits into
Open
Conversation
RUM on HarmonyOS collected at whatever rate the app was built with: moving that rate meant shipping a release and waiting for it to roll out, while the other platforms could already turn the knob from the console. The settings are read from the same endpoint the other SDKs use, at the rhythm of the sessions that consume them: once at start-up, once per new session, and on return to the foreground when the console asks for it. What arrives is stored, so the first session of a launch is already drawn under it. Nothing here can hold up initialisation or interrupt collection — a request that fails, times out or comes back unreadable leaves the stored values exactly as they were, because wiping them on a bad minute would swing a fleet back to the values it was built with, the opposite of what someone who moved a knob wants. A published rate applies to the NEXT session drawn; a session already under way is never re-decided. View documents now report the rate the session was actually drawn with plus the settings version, so extrapolation and audits line up with the draw that kept the session rather than with the init values. Two application-facing controls come with it: - setForcedSession() keeps a visitor the rate would have dropped — the support case where someone needs this one user's sessions whatever the fleet is on. - beforeSampling() has the last word on the rate, called synchronously at each draw with the rate that would apply and the console's custom values. A throw or an out-of-range answer is ignored: a mistake in the host application must not take collection down with it. Feature modules get no HarmonyOS Context of their own, so the credentials and the small amount of storage this needs come from the core, which already owns both. The demo app gains a scenario that drives the whole path from the command line.
Three things the first pass left behind: `stopSession`'s documentation ended up attached to a method inserted above it, two error-to-string helpers with one caller each where every other call site in this codebase writes the expression inline, and the same JSON-object parse in both the store and the controller — the store's is now shared, since the endpoint's body and the store's own entries need exactly the same tolerance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RUM on HarmonyOS collected at whatever rate the application was built with. Moving that rate meant shipping a release and waiting for it to roll out, while the other platforms could already turn the knob from the console. This adds the same remote configuration path here.
How it behaves
Settings are read from the RUM configuration endpoint at the rhythm of the sessions that consume them: once at start-up, once whenever a new session begins, and on return to the foreground when the console asks for it. What arrives is stored, so the first session of the next launch is already drawn under it.
A published rate applies to the next session drawn; a session already under way is never re-decided. View documents now report the rate the session was actually drawn with, plus the settings version, so extrapolation and audits line up with the draw that kept the session rather than with the values passed to init.
Nothing in this path can hold up initialisation or interrupt collection. A request that fails, times out or comes back unreadable leaves the stored values exactly as they were — wiping them on a bad minute would swing a whole fleet back to the values it was built with, which is the opposite of what someone who moved a knob deliberately wants. Retries are two per outage, spread by a jitter, then nothing until the next natural trigger.
Application-facing API
A hook that throws or returns a rate outside 0..100 is ignored: a mistake in the host application must not take collection down with it.
setForcedSession()keeps a session the rate would have dropped, and does nothing while a forced session is already running.Notes for reviewers
Context, so the credentials and the small amount of storage this needs come from the core, which already owns both:SdkCoregains an intake accessor and a two-method settings store.RemoteConfigStore/RemoteConfigController), with one deliberate difference: the drawn-configuration snapshot is held in memory rather than persisted, because nothing on this platform reads it back across launches.