RUM-17613 Flush the pending timeseries batch on backgrounding - #3715
Closed
satween wants to merge 2 commits into
Closed
RUM-17613 Flush the pending timeseries batch on backgrounding#3715satween wants to merge 2 commits into
satween wants to merge 2 commits into
Conversation
Rename the internal Timeseries interface to TimeseriesCollector and rename its implementations to DefaultTimeseriesCollector and DefaultTimeseriesCollectorFactory, propagating the new names through RumFeature, the RUM scope tree and the tests. No behaviour change. Ref: RUM-17613
Replace the collector's four-state enum with a generation-counted state and schedule a 200 ms deferred suspension when the app leaves the foreground, so the buffered batch is written instead of dropped. Sampling only runs on a foreground view, which makes the collectInBackground switch obsolete. Ref: RUM-17613
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
satween
force-pushed
the
tvaleev/feature/RUM-17613-1-collector-rename
branch
from
August 14, 2026 14:32
a90a51b to
71b5db2
Compare
Contributor
Author
|
Superseded: the background-collection fix now sits after the schema PR in the stack and carries the full RumContext migration. Replaced by #3717 (branch renamed to |
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.

What does this PR do?
Makes the timeseries collector flush its pending batch when the app leaves the foreground,
instead of dropping whatever was buffered.
The four-state
AtomicReference<State>enum is replaced by a generation-countedStateguarded by
synchronized. Leaving the foreground schedules a deferred suspension(
SUSPEND_DELAY_MS = 200) which, if the app is still not in the foreground when it fires,deactivates the current generation and flushes every pipeline. Returning to the foreground
cancels a suspension that has not fired yet, or starts a fresh sampling generation if it already
did. Sampling now only runs on a foreground view, so
onSessionStartneeds to know which viewthe session begins on —
TimeseriesCollector.Factory.createtakes aviewType, supplied byRumSessionScopefrom the active RUM context.Because sampling is unconditionally suspended outside the foreground,
TimeseriesConfiguration.Builder.collectInBackgroundno longer has anything to switch and isremoved together with its tests.
Motivation
Without this, a batch that is still filling when the user backgrounds the app is silently lost:
sampling was simply paused, and the buffer was only drained on session stop. The 200 ms debounce
mirrors
ActivityViewTrackingStrategy.STOP_VIEW_DELAY_MS, which guards the same race — anActivity-to-Activity transition briefly leaves no active view when the tracking strategy stops
the view on pause rather than on stop, and that must not be mistaken for backgrounding.
Additional Notes
The new
Statehas no terminalSTOPPED, soonSessionStartafteronSessionStopwouldrestart sampling. That invariant is now the caller's:
RumSessionScope.stopTimeseries()swaps ina
NoOpTimeseriesCollector, and a fresh collector is built per session. The test that assertedthe old terminal behaviour is dropped for that reason.
The three
AtomicReference<DefaultTimeseriesCollector.State>detekt safe-call entries go awaywith the
AtomicReference.api/apiSurfaceandapi/dd-sdk-android-rum.apiare unchanged — every removed member wasinternal(verified by re-runninggenerateApiSurface+apiDump).Instrumented tests are intentionally not part of this PR; they arrive with the last PR of the
stack.
Review checklist (to be filled by reviewers)
Ref: RUM-17613